# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1619515169 0 # Node ID 83f8f4f58a98ec1db0ccb38690fdd861b94903e1 # Parent cec43818bd3e65b249cbe7b4ede28c10874372cb Android: Implement dw_exit() using Activity.finishActivity() instead of exit(). diff -r cec43818bd3e -r 83f8f4f58a98 android/DWindows.kt --- 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. diff -r cec43818bd3e -r 83f8f4f58a98 android/dw.cpp --- 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); }