comparison android/dw.cpp @ 2496:3bf2f08fdc45

Android: Remove ugly workaround for initialization issues. Solved by a change to AndroidManifest.xml to prevent recreation on configuration changes. Add some code to detect the changes.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Mon, 03 May 2021 07:15:11 +0000
parents 5664c91d03fb
children 4ae2b3b77f25
comparison
equal deleted inserted replaced
2495:5664c91d03fb 2496:3bf2f08fdc45
87 JNIEXPORT void JNICALL 87 JNIEXPORT void JNICALL
88 Java_org_dbsoft_dwindows_DWindows_dwindowsInit(JNIEnv* env, jobject obj, jstring path) 88 Java_org_dbsoft_dwindows_DWindows_dwindowsInit(JNIEnv* env, jobject obj, jstring path)
89 { 89 {
90 static int runcount = 0; 90 static int runcount = 0;
91 91
92 /* Safety check to prevent multiple initializations... 92 /* Safety check to prevent multiple initializations... */
93 * In the simulator I get multiple calls, and code only works on the second call.
94 * On actual hardware we only get called once... so this works around that.
95 */
96 #if defined(__arm__) || defined(__aarch64__)
97 if(runcount == 0) 93 if(runcount == 0)
98 #else
99 if(runcount == 1)
100 #endif
101 { 94 {
102 char *arg = strdup(env->GetStringUTFChars((jstring) path, NULL)); 95 char *arg = strdup(env->GetStringUTFChars((jstring) path, NULL));
103 96
104 /* Save our class object pointer for later */ 97 /* Save our class object pointer for later */
105 _dw_obj = env->NewGlobalRef(obj); 98 _dw_obj = env->NewGlobalRef(obj);