changeset 2487:83f8f4f58a98

Android: Implement dw_exit() using Activity.finishActivity() instead of exit().
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Tue, 27 Apr 2021 09:19:29 +0000
parents cec43818bd3e
children 666af45f33b5
files android/DWindows.kt android/dw.cpp
diffstat 2 files changed, 17 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/android/DWindows.kt	Tue Apr 27 00:16:56 2021 +0000
+++ b/android/DWindows.kt	Tue Apr 27 09:19:29 2021 +0000
@@ -222,6 +222,11 @@
         return retval
     }
 
+    fun dwindowsExit(exitcode: Int)
+    {
+        this.finishActivity(exitcode)
+    }
+
     /*
      * Native methods that are implemented by the 'dwindows' native library,
      * which is packaged with this application.
--- a/android/dw.cpp	Tue Apr 27 00:16:56 2021 +0000
+++ b/android/dw.cpp	Tue Apr 27 09:19:29 2021 +0000
@@ -473,6 +473,18 @@
  */
 void API dw_exit(int exitcode)
 {
+    JNIEnv *env;
+
+    if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
+    {
+        // First get the class that contains the method you need to call
+        jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
+        // Get the method that you want to call
+        jmethodID dwindowsExit = env->GetMethodID(clazz, "dwindowsExit",
+                                                  "(I)V");
+        // Call the method on the object
+        env->CallVoidMethod(_dw_obj, dwindowsExit, exitcode);
+    }
     exit(exitcode);
 }