comparison android/dw.cpp @ 2511:0945d0428dfe

Android: New workaround for activity relaunch at startup. This workaround should prevent complete startup failure, but it does institute a 10 second delay, to see if we get called again. Hoping one day to figure out why this is happening and remove this completely, but if we can't, this delay can be used to show a splash screen in the future.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Fri, 07 May 2021 10:29:47 +0000
parents f54051c3f2a5
children 0fa54c340902
comparison
equal deleted inserted replaced
2510:f54051c3f2a5 2511:0945d0428dfe
85 * path: The path to the Android app. 85 * path: The path to the Android app.
86 */ 86 */
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 HEV startup = 0;
91 91
92 /* Safety check to prevent multiple initializations... */ 92 /* Safety check to prevent multiple initializations... */
93 #if defined(__arm__) || defined(__aarch64__) 93 if(startup)
94 if(runcount == 0) 94 {
95 #else 95 /* If we are called a second time.. post the event...
96 if(runcount == 1) 96 * so we stop waiting.
97 #endif 97 */
98 { 98 dw_event_post(startup);
99 char *arg = strdup(env->GetStringUTFChars((jstring) path, NULL)); 99 return;
100 }
101 else
102 {
103 char *arg;
104
105 /* Wait for a short while to see if we get called again...
106 * if we get called again we will be posted, if not...
107 * just wait for the timer to expire.
108 */
109 startup = dw_event_new();
110 /* Wait for 10 seconds to see if we get called again */
111 dw_event_wait(startup, 10000);
112
113 /* Continue after being posted or after our timeout */
114 arg = strdup(env->GetStringUTFChars((jstring) path, NULL));
100 115
101 /* Save our class object pointer for later */ 116 /* Save our class object pointer for later */
102 _dw_obj = env->NewGlobalRef(obj); 117 _dw_obj = env->NewGlobalRef(obj);
103 118
104 /* Save the JNIEnv for the main thread */ 119 /* Save the JNIEnv for the main thread */
109 _dw_main_event = dw_event_new(); 124 _dw_main_event = dw_event_new();
110 125
111 /* Launch the new thread to execute dwmain() */ 126 /* Launch the new thread to execute dwmain() */
112 dw_thread_new((void *) _dw_main_launch, arg, 0); 127 dw_thread_new((void *) _dw_main_launch, arg, 0);
113 } 128 }
114 runcount++;
115 } 129 }
116 130
117 typedef struct _sighandler 131 typedef struct _sighandler
118 { 132 {
119 struct _sighandler *next; 133 struct _sighandler *next;