# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1620383387 0 # Node ID 0945d0428dfee8c99a0f5cb730c671a7f014b34d # Parent f54051c3f2a50c892488e6bcc0293060171b6f07 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. diff -r f54051c3f2a5 -r 0945d0428dfe android/dw.cpp --- a/android/dw.cpp Fri May 07 09:35:14 2021 +0000 +++ b/android/dw.cpp Fri May 07 10:29:47 2021 +0000 @@ -87,16 +87,31 @@ JNIEXPORT void JNICALL Java_org_dbsoft_dwindows_DWindows_dwindowsInit(JNIEnv* env, jobject obj, jstring path) { - static int runcount = 0; + static HEV startup = 0; /* Safety check to prevent multiple initializations... */ -#if defined(__arm__) || defined(__aarch64__) - if(runcount == 0) -#else - if(runcount == 1) -#endif + if(startup) + { + /* If we are called a second time.. post the event... + * so we stop waiting. + */ + dw_event_post(startup); + return; + } + else { - char *arg = strdup(env->GetStringUTFChars((jstring) path, NULL)); + char *arg; + + /* Wait for a short while to see if we get called again... + * if we get called again we will be posted, if not... + * just wait for the timer to expire. + */ + startup = dw_event_new(); + /* Wait for 10 seconds to see if we get called again */ + dw_event_wait(startup, 10000); + + /* Continue after being posted or after our timeout */ + arg = strdup(env->GetStringUTFChars((jstring) path, NULL)); /* Save our class object pointer for later */ _dw_obj = env->NewGlobalRef(obj); @@ -111,7 +126,6 @@ /* Launch the new thread to execute dwmain() */ dw_thread_new((void *) _dw_main_launch, arg, 0); } - runcount++; } typedef struct _sighandler