mirror of https://github.com/encounter/SDL.git
Android: fix IllegalStateException in onBackPressed()
Rare exception, not catch-able, which appears when the activity gets in a broken state. java.lang.IllegalStateException: at android.app.FragmentManagerImpl.checkStateLoss (FragmentManagerImpl.java:1323) at android.app.FragmentManagerImpl.popBackStackImmediate (FragmentManagerImpl.java:493) at android.app.Activity.onBackPressed (Activity.java:2215) at org.libsdl.app.SDLActivity.onBackPressed (SDLActivity.java) at android.app.Activity.onKeyUp (Activity.java:2193) at android.view.KeyEvent.dispatch (KeyEvent.java:2685) at android.app.Activity.dispatchKeyEvent (Activity.java:2423) at org.libsdl.app.SDLActivity.dispatchKeyEvent (SDLActivity.java)
This commit is contained in:
parent
9996d1bb71
commit
f050309ee9
|
@ -453,8 +453,10 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
|
||||||
}
|
}
|
||||||
|
|
||||||
// Default system back button behavior.
|
// Default system back button behavior.
|
||||||
|
if (!isFinishing()) {
|
||||||
super.onBackPressed();
|
super.onBackPressed();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Called by JNI from SDL.
|
// Called by JNI from SDL.
|
||||||
public static void manualBackButton() {
|
public static void manualBackButton() {
|
||||||
|
@ -466,8 +468,10 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
|
||||||
runOnUiThread(new Runnable() {
|
runOnUiThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
if (!SDLActivity.this.isFinishing()) {
|
||||||
SDLActivity.this.superOnBackPressed();
|
SDLActivity.this.superOnBackPressed();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue