Even something as seemingly harmless as a static bool can mess up your
application: Say you have a static bool that tells you whether OpenGL
has been initialized. Well, it'll be wrong when the application is run a
second time, because you'll have a new OpenGL state to contend with.
Similarly for any static state that is trying to track any global
application state or Java-related state.
Tim
I think it's only a problem if you don't play nice with the Android life cycle. Use Activity.onDestroy as an opportunity to reset your native context.
/* * When the android framework launches a second instance of * an activity, the new instance's onCreate() method may be * called before the first instance returns from onDestroy(). * * This semaphore ensures that only one instance at a time * accesses EGL. */
Sorry if my info was wrong. This is certainly worth noting. Do you have a code sample for detecting a new jvm?
JNIEXPORT void JNICALL Java_com_recharge_quickcharge_QcEventDispatch_qcShutDown (JNIEnv * env, jobject obj) { if (!env->IsSameObject(gCurrentEventDispatch,obj)) { LOGI("Ignoring a shutdown from the old process"); return; } qcDoShutdown(); }