Android: Fixed deadlock in AndroidHarness.onDestroy() and added screenOrientation

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7791 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
kim..ng 14 years ago
parent 42feb50b76
commit ef6b7157b9
  1. 43
      engine/src/android/com/jme3/app/AndroidHarness.java

@ -5,6 +5,7 @@ import java.util.logging.Logger;
import android.app.Activity; import android.app.Activity;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.pm.ActivityInfo;
import android.opengl.GLSurfaceView; import android.opengl.GLSurfaceView;
import android.os.Bundle; import android.os.Bundle;
import android.view.SurfaceView; import android.view.SurfaceView;
@ -64,10 +65,24 @@ public class AndroidHarness extends Activity implements TouchListener, DialogInt
*/ */
protected String exitDialogMessage = "Use your home key to bring this app into the background or exit to terminate it."; protected String exitDialogMessage = "Use your home key to bring this app into the background or exit to terminate it.";
/**
* Set the screen orientation, default is SENSOR
* ActivityInfo.SCREEN_ORIENTATION_* constants
* package android.content.pm.ActivityInfo
*
* SCREEN_ORIENTATION_UNSPECIFIED
* SCREEN_ORIENTATION_LANDSCAPE
* SCREEN_ORIENTATION_PORTRAIT
* SCREEN_ORIENTATION_USER
* SCREEN_ORIENTATION_BEHIND
* SCREEN_ORIENTATION_SENSOR (default)
* SCREEN_ORIENTATION_NOSENSOR
*/
protected int screenOrientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR;
protected OGLESContext ctx; protected OGLESContext ctx;
protected GLSurfaceView view; protected GLSurfaceView view;
protected boolean isGLThreadPaused = true;
final private String ESCAPE_EVENT = "TouchEscape"; final private String ESCAPE_EVENT = "TouchEscape";
@Override @Override
@ -81,7 +96,9 @@ public class AndroidHarness extends Activity implements TouchListener, DialogInt
requestWindowFeature(Window.FEATURE_NO_TITLE); requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN); WindowManager.LayoutParams.FLAG_FULLSCREEN);
setRequestedOrientation(screenOrientation);
AppSettings settings = new AppSettings(true); AppSettings settings = new AppSettings(true);
AndroidInput input = new AndroidInput(this); AndroidInput input = new AndroidInput(this);
@ -110,7 +127,8 @@ public class AndroidHarness extends Activity implements TouchListener, DialogInt
@Override @Override
protected void onRestart(){ protected void onRestart()
{
super.onRestart(); super.onRestart();
if (app != null) if (app != null)
app.restart(); app.restart();
@ -119,37 +137,44 @@ public class AndroidHarness extends Activity implements TouchListener, DialogInt
@Override @Override
protected void onStart(){ protected void onStart()
{
super.onStart(); super.onStart();
logger.info("onStart"); logger.info("onStart");
} }
@Override @Override
protected void onResume() { protected void onResume()
{
super.onResume(); super.onResume();
if (view != null) if (view != null)
view.onResume(); view.onResume();
isGLThreadPaused = false;
logger.info("onResume"); logger.info("onResume");
} }
@Override @Override
protected void onPause() { protected void onPause()
{
super.onPause(); super.onPause();
if (view != null) if (view != null)
view.onPause(); view.onPause();
isGLThreadPaused = true;
logger.info("onPause"); logger.info("onPause");
} }
@Override @Override
protected void onStop(){ protected void onStop()
{
super.onStop(); super.onStop();
logger.info("onStop"); logger.info("onStop");
} }
@Override @Override
protected void onDestroy(){ protected void onDestroy()
{
if (app != null) if (app != null)
app.stop(true); app.stop(! isGLThreadPaused);
super.onDestroy(); super.onDestroy();
logger.info("onDestroy"); logger.info("onDestroy");
} }

Loading…
Cancel
Save