If the activity is not active when the service connection is
established and handleIntent() is called, the activity's state is already
saved and any fragment transaction would result in an illegalStateException
due to state loss. We just ignore this and wait for another initiation
attempt (via onNewIntent()).
if (!pm.isIgnoringBatteryOptimizations(this.getPackageName()) &&
!pref.getBoolean(Constants.PREF_IGNORE_POWER_WHITELIST, false))
{
+ if (getSupportFragmentManager().isStateSaved())
+ { /* we might get called via service connection and manual onActivityResult()
+ * call when the activity is not active anymore and fragment transactions
+ * would cause an illegalStateException */
+ return false;
+ }
PowerWhitelistRequired whitelist = new PowerWhitelistRequired();
whitelist.show(getSupportFragmentManager(), DIALOG_TAG);
return false;