Steps:
- Request a permission from
Fragment
orActivity
- Show a DialogFragment from within
onRequestPermissionsResult()
java.lang.IllegalStateException
is thrown: Can not perform this action afteronSaveInstanceState
This doesn't happen when I show dialog after some delay(using postDelayed).
According to http://www.androiddesignpatterns.com/2013/08/fragment-transaction-commit-state-loss.html) on post-Honeycomb devices we CAN commit()
between onPause()
and onStop()
without any STATE LOSS or EXCEPTION.
Here is a link to sample project source, log file and issue recorded.
https://drive.google.com/folderview?id=0BwvvuYbQTUl6STVSZF9TX2VUeHM&usp=sharing
Also I have opened an issue https://code.google.com/p/android/issues/detail?id=190966 but it was marked as WorkingAsIntended and they suggest to just catch exception. But this doesn't solve the issue. I know other ways to solve it, but isn't this android bug?
UPDATE Status fo the bug is again "assigned". Hope it will be fixed soon. My temp solution is
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
// do your fragment transaction here
}
}, 200);