Suppose you have two activities: A (launcher) and B. Activity A has a button, when you press it, activity B is started for result. When the user presses the back key, in the method onActivityResult()
of activity A, put a call to the method recreate()
. What happens is that the activity A is recreated, resumed and automatically paused (that is, the onPause()
method is called after onResume()
, but the activity is fully visible, of course). This happens on the emulator, api level 16,17,18,19,21,22,23. This does not happen on a real api 23 smartphone. You can put a flag inside onActivityResult()
and call the recreate()
method from onResume()
and get the same result. Is this a bug of android emulators or am i missing something?
A part of the gradle file:
compileSdkVersion 27
defaultConfig {
applicationId "com.test.test2"
minSdkVersion 16
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
Update
I see that someone else found the same strange behaviour: stackoverflow question. I think i have added some more info.