Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8097192

Android finish on Platform.exit

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 8u40
    • javafx

      On Android, calling Platform.exit() should result in closing the Activity. At this moment, the render thread is stopped but the Activity is still active, resulting in a black sceen.
      The following patch registers a FinishListener with the PlatformImpl, and on callback this listener will finish the Android activity:
      diff -r 92fcf0f1d66d modules/graphics/src/dalvik/java/javafxports/android/DalvikLauncher.java
      --- a/modules/graphics/src/dalvik/java/javafxports/android/DalvikLauncher.java Wed Nov 26 11:29:59 2014 +0100
      +++ b/modules/graphics/src/dalvik/java/javafxports/android/DalvikLauncher.java Fri Nov 28 10:03:06 2014 +0100
      @@ -37,6 +37,8 @@
       import java.lang.reflect.Method;
       import java.util.Map.Entry;
       import java.util.Properties;
      +import com.sun.javafx.application.PlatformImpl;
      +import com.sun.javafx.application.PlatformImpl.FinishListener;
       
       public class DalvikLauncher implements Launcher {
       
      @@ -175,8 +177,24 @@
               FXActivity.getInstance().setOnSurfaceChangedNativeMethod2(dalvikInputClass.getMethod("onSurfaceChangedNative", int.class, int.class, int.class));
               FXActivity.getInstance().setOnSurfaceRedrawNeededNativeMethod(dalvikInputClass.getMethod("onSurfaceRedrawNeededNative"));
               FXActivity.getInstance().setOnConfigurationChangedNativeMethod(dalvikInputClass.getMethod("onConfigurationChangedNative", int.class));
      + registerExitListener();
           }
       
      + private void registerExitListener() {
      + FinishListener l = new FinishListener() {
      + public void idle(boolean implicitExit) {
      + Log.v (TAG, "FinishListener idle called with exit = "+implicitExit);
      + activity.finish();
      + }
      + public void exitCalled() {
      + Log.v (TAG, "FinishListener exit called");
      + activity.finish();
      + }
      + };
      + PlatformImpl.addListener(l);
      + }
      +
      +
           private Class resolveApplicationClass()
                   throws PackageManager.NameNotFoundException, ClassNotFoundException {
       

            kcr Kevin Rushforth
            jvos Johan Vos
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: