Answer the question
In order to leave comments, you need to log in
How to return correctly?
Good afternoon!
Let's say there are 2 activities - MainActivity & FavoriteActivity with recyclerview. When clicking on the recyclerview element, the third activity InfoActivity opens.
How to correctly return the user when clicking "Back" depending on which Activity he moved from?
The problem is that in the manifest for an InfoActivity, you can only specify 1 activity as a parent. And of course, the return logic cannot be written in the manifest depending on which activity the user switched from ...
<activity
android:parentActivityName=".MainActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="info.md7.dermanlar.MainActivity" />
......
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
Answer the question
In order to leave comments, you need to log in
Handle the up click in code:
override fun onOptionsItemSelected(item: MenuItem): Boolean {
if (item.itemId == android.R.id.home) finish()
return super.onOptionsItemSelected(item)
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question