I have a very simple app based on the Building Your First App tutorial. There are two activities: MainActivity
invokes DisplayMessageActivity
thro
Adding launchMode in Manifest changes launch mode every time, even it is not launched by child activity. There are other ways to launch existed instance.
1.override onOptionsItemSelected(item: MenuItem)
override fun onOptionsItemSelected(item: MenuItem): Boolean {
return when (item.itemId) {
android.R.id.home -> {
// Respond to the action bar's Up/Home button
val upIntent: Intent? = NavUtils.getParentActivityIntent(this)
when {
upIntent == null -> throw IllegalStateException("No Parent Activity Intent")
else -> {
//add launch flag here
upIntent.flags=Intent.FLAG_ACTIVITY_CLEAR_TOP
NavUtils.navigateUpTo(this, upIntent)
}
}
true
}
else -> super.onOptionsItemSelected(item)
}
}