I'm starting Android development and am facing problems regarding activity lifecycle. I have an Activity A that calls Activity B in its onCreate() method (Activity B has a custom grid view inside a relative layout).
When in Activity B, if the screen orientation remains unchanged and back button is pressed, as expected it goes to Activity A's onResume() method. However, on changing screen orientation while in Activity B, on later pressing back button, it goes to Activity A's onCreate() method thereby recreating Activity B (as Activity A calls B in its onCreate() ). Only on pressing the back button twice does it go back to Activity A's onResume() method. How do I ensure that on changing orientation, I go to Activity A's onResume() by pressing back button just once?
I've tried including
android:configChanges="keyboardHidden|screenSize|orientation"
in Activity B in manifest and hence this avoids calling Activity B's onCreate on changing orientation but it still doesn't solve my problem.
Aucun commentaire:
Enregistrer un commentaire