I have the following code in my onActivityResult for a fragment of mine:
onActivityResult(int requestCode, int resultCode, Intent data){
//other code
P
It happens because when #onActivityResult() is called, the parent activity has already call #onSaveInstanceState()
I would use a Runnable to "save" the action (show dialog) on #onActivityResult() to use it later when activity has been ready.
With this approach we make sure the action we want to will always work
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == YOUR_REQUEST_CODE) {
mRunnable = new Runnable() {
@Override
public void run() {
showDialog();
}
};
} else {
super.onActivityResult(requestCode, resultCode, data);
}
}
@Override
public void onStart() {
super.onStart();
if (mRunnable != null) {
mRunnable.run();
mRunnable = null;
}
}