Browse Source

Android : OGLESContext can now finish the activity when being destroyed, this way calling app.stop() from jME finished the associated activity.
This feature can be disabled by setting a flag in the MainActivity.

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9234 75d07b2b-3a1a-0410-a2c5-0572b91ccdca

rem..om 13 years ago
parent
commit
d2b727cfd8

+ 10 - 0
engine/src/android/com/jme3/app/AndroidHarness.java

@@ -69,6 +69,10 @@ public class AndroidHarness extends Activity implements TouchListener, DialogInt
      * Flip Y axis
      */
     protected boolean mouseEventsInvertY = true;
+    /**
+     * if true finish this activity when the jme app is stopped
+     */
+    protected boolean finishOnAppStop = true;
     /**
      * Title of the exit dialog, default is "Do you want to exit?"
      */
@@ -395,4 +399,10 @@ public class AndroidHarness extends Activity implements TouchListener, DialogInt
             }
         }
     }
+
+    public boolean isFinishOnAppStop() {
+        return finishOnAppStop;
+    }
+    
+    
 }

+ 7 - 0
engine/src/android/com/jme3/system/android/OGLESContext.java

@@ -282,6 +282,13 @@ public class OGLESContext implements JmeContext, GLSurfaceView.Renderer, SoftTex
             logger.info("Display destroyed.");
 
             renderable.set(false);
+            final Context ctx = this.view.getContext();
+            if (ctx instanceof AndroidHarness) {
+                AndroidHarness harness = (AndroidHarness) ctx;
+                if (harness.isFinishOnAppStop()) {
+                    harness.finish();
+                }
+            }
         }
     }