Skip to content

Instantly share code, notes, and snippets.

@AOrobator
Last active December 18, 2016 23:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AOrobator/73b77d06bcfa77f109a43d7d14dec347 to your computer and use it in GitHub Desktop.
Save AOrobator/73b77d06bcfa77f109a43d7d14dec347 to your computer and use it in GitHub Desktop.
Implementing App Shortcuts - Enabling/Disabling Shortcuts
@TargetApi(N_MR1)
override fun onOptionsItemSelected(item: MenuItem): Boolean {
when (item.itemId) {
R.id.enable_shortcut -> shortcutAction {
it.enableShortcuts(listOf(constellation.name))
alertUser(R.string.shortcut_enabled)
}
R.id.disable_shortcut -> shortcutAction {
it.disableShortcuts(listOf(constellation.name))
alertUser(R.string.shortcut_disabled)
}
android.R.id.home -> finish()
}
return true
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment