I have a Tab
A, B and C. All ofthem contain a ListView
called Aa, Bb and Cc. When I click on an item in one of these ListView
s I want to show a new activity which will display the information of that clicked item. I have enabled the button in the ActionBar
which takes me to the parent Activity
. However always when I click that button it does take me to the parent activity but a whole different tab is selected and it loads everything again (data for the listviews). Basically it's the same as when I would start the application.
What I want is to go back to the last "state" of my parent activity. I overrode the onNavigateUp() method.
@Override
public boolean onNavigateUp() {
onBackPressed();
return false;
}
This works. It goes back to the parent activity and shows it in the state I left it, that is, the tab I was in is still selected and the ListView
shows me the items I last saw.
However, now I want to show a notification when I clicked a button in my display Activity
. And when I click that notification it should take me to the display Activity
.
So far so good but when I click that button so that the Notification shows up and I click on that notification, it takes me again to the display Activity. But the problem is, it is already open and when I click on the navigateUpButton
it takes me to the last activity I was showing before so it's the display Activity again. I would have to click it again to show the parent activity.
I hope my problem is clear. How can I show the parent activity in its last showed state when I click that navigateUpButton
?
Edit:
I saw in a similar question an approach to add this to my activity in the manifest file :
android:alwaysRetainTaskState="True"
android:launchMode="singleInstance"
It worked, I can now only use one instance. When I click it and I am still in my display Activity it takes me back to my parent Activity. However, when I am in my home screen and click that notification, the display Activity shows up and then with the navigateUpButton
I get back to my home screen and not back to my parent Activity
.