Skip to content

com.android.launcher.action.INSTALL_SHORTCUT is NOT supported in Android 8.0. ShortcutManager is a new way to create a pinned shortcut on home screen

License

Notifications You must be signed in to change notification settings

takeo-asai/oreo-shortcut-manager

Repository files navigation

oreo-shortcut

Android 8 Oreo (API 26) does NOT support an old BROADCAST way to create a pinned shortcut on home screen.

// before Android 7.1
Intent intent = new Intent("com.android.launcher.action.INSTALL_SHORTCUT");
...
sendBroadcast(intent);

New Android 8 supports a new API way to create one.

ShortcutManager#requestPinShortcut()

// after Android 8.0
val manager = getSystemService(Context.SHORTCUT_SERVICE) as ShortcutManager
val info = ShortcutInfo.Builder(this, "shortcut-id")
    .setShortLabel("label")
    .setIcon(Icon.createWithResource(this, R.mipmap.ic_launcher_round))
    .setIntent(intent)
    .build()
manager.requestPinShortcut(info, null)

About

com.android.launcher.action.INSTALL_SHORTCUT is NOT supported in Android 8.0. ShortcutManager is a new way to create a pinned shortcut on home screen

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages