Skip to content

Instantly share code, notes, and snippets.

@realdm
Created June 6, 2018 09:16
Show Gist options
  • Save realdm/3c9084189be077dda9b022058b1ae828 to your computer and use it in GitHub Desktop.
Save realdm/3c9084189be077dda9b022058b1ae828 to your computer and use it in GitHub Desktop.
toolbar.setNavigationOnClickListener {
val upIntent: Intent? = NavUtils.getParentActivityIntent(activity!!)
when {
upIntent == null -> throw IllegalStateException("No Parent Activity Intent")
NavUtils.shouldUpRecreateTask(activity!!, upIntent) -> {
TaskStackBuilder.create(activity!!)
.addNextIntentWithParentStack(upIntent)
.startActivities()
}
else -> {
NavUtils.navigateUpTo(activity!!, upIntent)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment