I have the following situation:
One Main ListActivity
. The list consists of POJO objects, each item is a different POJO.
Each POJO contains different groups. For each group I made different Activity
.
Lets say POJO1 contains groups A, B and C, when pressed, ActivityA will be opened and the navigation between the rest activities ActivityB and ActivityC is done using NavigationDrawer
.
All group activities implement a custom class MyNavigationDrawerClass which is the core of the Navigation Drawer
in my app.
Each ActivityA, B, C, etc, has a SettingsActivity which is strictly individual and depends on from where it has been started.
Now the question is: How to navigate from any A, B, C, etc, activity to the Main ListActivity every time the BackButton
is pressed?
I will provide an example:
- App is started - Main List Activity is showed;
- Item is pressed and ActivityA with
NavigationDrawer
is started; - The
NavigationDrawer
is opened and ActivityC is opened; - When
BackButton
is pressed, the user is navigated back to ActivityA, but my desire is to navigate the user to the Main List Activity
What I tried:
- To put
android:noHistory="true"
for every ActivityA, ActivityB and ActivityC in theAndroidManifest
. That did not work because when I open the SettingsActivity for example from ActivityA and return, the user in navigated to the Main List Activity, and not to the ActivityA - it's confusing and misleading. - To override
onBackPressed
in MyNavigationDrawerClass and start the Main List Activity usingIntent
. That did not work either because there are still previous activities in the stack and when theBackButton
is pressed from Main List Activity, the user is navigated to them.
I hope I explained the situation clearly.
Any help will be appreciated.