Android: Fixed bug in AndroidHarness if appClass can not be found
git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7778 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
e44d581fea
commit
c58f429543
@ -7,8 +7,11 @@ import android.app.AlertDialog;
|
|||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.opengl.GLSurfaceView;
|
import android.opengl.GLSurfaceView;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.view.SurfaceView;
|
||||||
|
import android.view.View;
|
||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.jme3.app.Application;
|
import com.jme3.app.Application;
|
||||||
import com.jme3.input.TouchInput;
|
import com.jme3.input.TouchInput;
|
||||||
@ -83,13 +86,14 @@ public class AndroidHarness extends Activity implements TouchListener, DialogInt
|
|||||||
AndroidInput input = new AndroidInput(this);
|
AndroidInput input = new AndroidInput(this);
|
||||||
|
|
||||||
// Create application instance
|
// Create application instance
|
||||||
try{
|
try
|
||||||
|
{
|
||||||
|
app = null;
|
||||||
|
view = null;
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
Class<? extends Application> clazz = (Class<? extends Application>) Class.forName(appClass);
|
Class<? extends Application> clazz = (Class<? extends Application>) Class.forName(appClass);
|
||||||
app = clazz.newInstance();
|
app = clazz.newInstance();
|
||||||
}catch (Exception ex){
|
|
||||||
handleError("Class " + appClass + " init failed", ex);
|
|
||||||
}
|
|
||||||
|
|
||||||
app.setSettings(settings);
|
app.setSettings(settings);
|
||||||
app.start();
|
app.start();
|
||||||
@ -97,11 +101,18 @@ public class AndroidHarness extends Activity implements TouchListener, DialogInt
|
|||||||
view = ctx.createView(input, eglConfigType, eglConfigVerboseLogging);
|
view = ctx.createView(input, eglConfigType, eglConfigVerboseLogging);
|
||||||
setContentView(view);
|
setContentView(view);
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
handleError("Class " + appClass + " init failed", ex);
|
||||||
|
setContentView(new TextView(this));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onRestart(){
|
protected void onRestart(){
|
||||||
super.onRestart();
|
super.onRestart();
|
||||||
|
if (app != null)
|
||||||
app.restart();
|
app.restart();
|
||||||
logger.info("onRestart");
|
logger.info("onRestart");
|
||||||
}
|
}
|
||||||
@ -116,6 +127,7 @@ public class AndroidHarness extends Activity implements TouchListener, DialogInt
|
|||||||
@Override
|
@Override
|
||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
if (view != null)
|
||||||
view.onResume();
|
view.onResume();
|
||||||
logger.info("onResume");
|
logger.info("onResume");
|
||||||
}
|
}
|
||||||
@ -123,6 +135,7 @@ public class AndroidHarness extends Activity implements TouchListener, DialogInt
|
|||||||
@Override
|
@Override
|
||||||
protected void onPause() {
|
protected void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
|
if (view != null)
|
||||||
view.onPause();
|
view.onPause();
|
||||||
logger.info("onPause");
|
logger.info("onPause");
|
||||||
}
|
}
|
||||||
@ -135,6 +148,7 @@ public class AndroidHarness extends Activity implements TouchListener, DialogInt
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDestroy(){
|
protected void onDestroy(){
|
||||||
|
if (app != null)
|
||||||
app.stop(true);
|
app.stop(true);
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
logger.info("onDestroy");
|
logger.info("onDestroy");
|
||||||
@ -193,6 +207,7 @@ public class AndroidHarness extends Activity implements TouchListener, DialogInt
|
|||||||
{
|
{
|
||||||
if (whichButton != -2)
|
if (whichButton != -2)
|
||||||
{
|
{
|
||||||
|
if (app != null)
|
||||||
app.stop(true);
|
app.stop(true);
|
||||||
this.finish();
|
this.finish();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user