My application allows the users to browse around in certain child activities FileListActivity
owned by a parent MainActivity
. When the user clicks e.g. home button, the app goes to background.
Problem:
When the user opens the app via PendingIntent
or from history, the child activity FileListActivity
is shown. Pressing the back button from here closes the app (sends app to background).
Visualized flow:
MainActivity
opensFileListActivity
App goes to background, but FileListActivity
should close and return to MainActivity
Question:
Using something like
startActivity(new Intent(MainActivity.this, FileListActivity.class));
How can I ensure that when the user reopens the app onto the child activity and presses the back button that the app returns to MainActivity
and doesn't go to background?
I know I should be using IntentFlags, just not sure which to use.
FLAG_ACTIVITY_RETAIN_IN_RECENTS
may do the trick
Or
You startActivityForResult
instead of startActivity
.
refer the android dev for more info here.