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

Android finish on Platform.exit

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Duplicate
    • Affects Version/s: 8u40
    • Fix Version/s: None
    • Component/s: javafx
    • Labels:

      Description

      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 {
       

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                Created:
                Updated:
                Resolved:
                Imported: