Skip to content

Commit 71799c7

Browse files
committed
ANDROID: try harder to handle onStop and onPause
Note: This is at the moment meant for evaluation. Works for me, can't break it. However if this is going to be the final call, those file names ANDROID_java_oncreate are no longer telling exactly where the code ends up. That's bad, bnut renaming them is likely even worse.
1 parent 8d0d7ed commit 71799c7

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

loaders/android/bootstrap.c.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ JNIEnv* GetJNIEnv(){
115115
if(s_vm) {
116116
// some say that despite AttachCurrentThread being a no-op, one
117117
// may save overhead when checking first via GetEnv, so we do.
118-
error = (*s_vm)->GetEnv(s_vm, &env, LAMBDANATIVE_JNI_VERSION);
118+
error = (*s_vm)->GetEnv(s_vm, (void**)&env, LAMBDANATIVE_JNI_VERSION);
119119
if(error==JNI_EDETACHED) {
120120
error=(*s_vm)->AttachCurrentThreadAsDaemon(s_vm, &env, NULL);
121121
}

loaders/android/bootstrap.java.in

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -194,23 +194,28 @@ public class @SYS_APPNAME@ extends Activity implements @ANDROID_JAVA_IMPLEMENTS@
194194
nativeEvent(127,0,0); // EVENT_TERMINATE
195195
super.onDestroy();
196196
}
197+
private void onPauseOrStop() {
198+
// Additions needed by modules, e.g. gps
199+
@ANDROID_JAVA_ONPAUSE@
200+
if (!isFinishing() && current_ContentView==mGLView && mGLView!=null) {
201+
mGLView.onPause();
202+
}
203+
}
197204
@Override
198205
protected void onStop() {
206+
Log.e("@SYS_PACKAGE_DOT@", "onStop");
207+
onPauseOrStop();
199208
super.onStop();
200209
}
201210
@Override
202211
protected void onPause() {
203-
// Additions needed by modules, e.g. gps
204-
@ANDROID_JAVA_ONPAUSE@
205-
if (!isFinishing() && current_ContentView==mGLView) {
206-
mGLView.onPause();
207-
}
212+
onPauseOrStop();
208213
super.onPause();
209214
}
210215
@Override
211216
protected void onResume() {
212217
super.onResume();
213-
if(current_ContentView==mGLView) {
218+
if(current_ContentView==mGLView && mGLView!=null) {
214219
mGLView.onResume();
215220
}
216221
// Additions needed by modules, e.g. gps

0 commit comments

Comments
 (0)