Back button in an Activity without recreate previous Activity (Android) -
I have a master activity that is menu (A). Activity A has 6 pieces. One of them is a gallery of pictures (Figure 1). When you touch a picture, you go to the image description activity (B) (Figure 2). I add the tag "parent name" to Activity B in AndroidManifest.xml. So is the parent activity of activity B A. The problem is: When you are in Activity B and you press the button above (Figure 2) the activity is manufactured and it shows the first piece of activity A (no gallery piece). When you come back to the previous activity, I want to do the same thing as the Instragram application. It seems that the Instagram app does not recreate past activity. The expected behavior is similar to the behavior of the back button (Figure 3). How can I get this behavior? Thank you
Picture 1. Picture Details Activity
Figure 2 . Image description activity
figure 3 Back button
I have solved my problem easily. android: launchMode = "singleTop" had to be added. I also add the next code in Activity A but maybe this is not necessary. I hope you find it useful
Protected over @OverrideSaveInstanceState (bundle outstate) {super.onSaveInstanceState (outstate); } @ Override Protected Zero to Restore InstantState (InstanceState saved from bundle) {Super. Restore InstantState (Saved Instantstate); }
Comments
Post a Comment