Skip to content

Commit d86a516

Browse files
committed
ANDROID: moved setContentView to after permissions
Calling setContentView between permission requests would cause some apps to hang. This problem was previously addressed by adding a shell override function for onRequestPermissionResult, which is no longer needed and is removed in this commit
1 parent 1f656d1 commit d86a516

File tree

1 file changed

+4
-14
lines changed

1 file changed

+4
-14
lines changed

loaders/android/bootstrap.java.in

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -107,17 +107,6 @@ public class @SYS_APPNAME@ extends Activity implements @ANDROID_JAVA_IMPLEMENTS@
107107
return true;
108108
}
109109

110-
@IF_ANDROIDAPI_GT_22@
111-
@Override
112-
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
113-
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
114-
//Must do something with results data or app will hang
115-
int rc = requestCode;
116-
String p = permissions[0];
117-
int gr = grantResults[0];
118-
}
119-
/* end of IF_ANDROIDAPI_GT_22 */
120-
121110
@Override
122111
public void startActivityForResult(Intent intent, int cont) {
123112
try {
@@ -185,12 +174,13 @@ public class @SYS_APPNAME@ extends Activity implements @ANDROID_JAVA_IMPLEMENTS@
185174
nativeInstanceInit(getApplicationContext().getPackageCodePath().toString(), getFilesDir().toString());
186175

187176
mSensorManager = (SensorManager)getSystemService(Context.SENSOR_SERVICE);
188-
checkOrRequestPermission(android.Manifest.permission.WRITE_EXTERNAL_STORAGE);
189-
setContentView(mGLView); // MUST NOT run before nativeInstanceInit completed
190177

191-
// Additions needed by modules, e.g. gps
178+
checkOrRequestPermission(android.Manifest.permission.WRITE_EXTERNAL_STORAGE);
179+
// Additions and permissions needed by modules, e.g. gps
192180
@ANDROID_JAVA_ONCREATE@
193181

182+
setContentView(mGLView); // MUST NOT run before nativeInstanceInit completed
183+
194184
// start EVENT_IDLE
195185
if(idle_tmScheduleRate > 0) idle_tm.scheduleAtFixedRate(idle_task, 0, idle_tmScheduleRate);
196186
}

0 commit comments

Comments
 (0)