android: Prevent illegalStateException when showing power whitelist dialog
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()).
This commit is contained in:
parent
264435f626
commit
80337f4f9d
|
@ -205,6 +205,12 @@ public class VpnProfileControlActivity extends AppCompatActivity
|
|||
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;
|
||||
|
|
Loading…
Reference in New Issue