I have within an Activity, called CounterActivity
, a counter that counts let's say from 100 down to 0 with a second interval. A DialogFrament
is shown when the counter gets to 0 as follows:
MessageFragment dialog = new MessageFragment();
dialog.show(getSupportFragmentManager(), "MessageFragment");
The main layout of that activity has the following attribute set android:keepScreenOn="true"
,that way the screen will not timeout as long as the activity is visible. If I then open another application then onStop is called on CounterActivity
. If the counter, which is still running in the background, gets to 0 instead of showing the DialogFragment the following exception is thrown:
java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState