-
-
Save cybercoder-naj/268fececded1c6aa77fedc0e50667b15 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const val SHORTCUT_SECOND_ID = "id_second" | |
@RequiresApi(Build.VERSION_CODES.N_MR1) | |
fun createNewShortcut() { | |
val shortcutManager = getSystemService(context, ShortcutManager::class.java) | |
val secondActivity = ShortcutInfo.Builder(context, SHORTCUT_SECOND_ID) | |
.setShortLabel("Main") | |
.setIntents(arrayOf( | |
/* you should start with the Launcher Activity */ | |
Intent(Intent.ACTION_VIEW, null, context, MainActivity::class.java), | |
Intent(Intent.ACTION_VIEW, null, context, SecondActivity::class.java) | |
)) | |
.build() | |
shortcutManager!!.dynamicShortcuts = listOf(secondActivity) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment