in my app there's an Activity with a Navigation Drawer. The selection of the drawer's items brings to the instantiation of related List Fragments. When I select an item in the List Fragment, a second Activity begins showing information about the item I clicked. Navigating back to the first Activity, it gets created again, but I'd like to keep track of the last fragment showed, with the list from which I selected the item. How could I achieve this? Thanks in advance.
Asked
Active
Viewed 104 times
-2
-
make use of **.addToBackStack()** – debugger Jul 17 '17 at 07:44
-
Cannot open New Activity to show information about the item you can open another fragment and add this fragment to backstack and then navigate back to it call the first frgament . – Sardar Khan Jul 17 '17 at 07:47
-
In your manifest did you try adding android:launchMode="singleTop" to your first Activity? – Mohammed Junaid Jul 17 '17 at 07:54
-
Does selecting an item starts a fragment or an acitivity? because this statement is making question confusing. "When I select an item in the List Fragment, a second Activity begins showing information about the item I clicked." – Mohammed Junaid Jul 17 '17 at 07:56
-
@MohammedJunaid I tried with `android:launchMode="singleTop"` and seems working! Thank you! – paola91 Jul 17 '17 at 09:08
-
@px91 great. posted it as answer. – Mohammed Junaid Jul 17 '17 at 09:20
-
Possible duplicate of [Custom Back Stack for each Fragment in TabHost in Android](https://stackoverflow.com/questions/12854105/custom-back-stack-for-each-fragment-in-tabhost-in-android) – Android Boy Jul 17 '17 at 09:32
1 Answers
1
Add
android:launchMode="singleTop"
to your first Activity in your manifest file.

Mohammed Junaid
- 1,362
- 14
- 18