How to create dynamic app shortcut using ShortcutManager API for android 7.1 app?

create app shortcut android programmatically
android create shortcut on app install
android app shortcuts not showing
pinned shortcuts android example
android app shortcut icon size
how to create shortcut for android studio in windows 10
all apps shortcut android
android app info'' shortcut

In Android 7.1, developer can able to create AppShortCut.

We can create shortcut in two way:

  1. Static shortcuts using resources(XML) file.
  2. Dynamic shortcuts using ShortcutManager API.

So How to create a shortcut using ShortcutManager dynamically?

Creating App Shortcuts in Launcher, Android 7.1 allows you to define shortcuts to specific actions in your app. To implement it you have to start with downloading the latest SDK (API level 25). To create a Dynamic Shortcut you will have to use these codes in your activity where you ShortcutManager sM = getSystemService(ShortcutManager.class); Intent  Android app shortcuts are a special feature added in Android 7.1 (API 25). Shortcuts are special actions that appear when you long press on a launcher icon, that will trigger a specified intent. With this post you will learn how to create both static and dynamic app shortcuts. The only pre-requisite is that your app is targeting API 25 or greater.

We can use ShortcutManager for a intent action like this

ShortcutManager shortcutManager = getSystemService(ShortcutManager.class);

ShortcutInfo webShortcut = new ShortcutInfo.Builder(this, "shortcut_web")
        .setLongLabel("Open web site")
        .setIcon(Icon.createWithResource(this, R.drawable.ic_dynamic_shortcut))
        .setIntent(new Intent(Intent.ACTION_VIEW, Uri.parse("")))


we can use ShortcutManager to open an activity like this

    ShortcutInfo dynamicShortcut = new ShortcutInfo.Builder(this, "shortcut_dynamic")
        .setLongLabel("Open dynamic shortcut")
        .setIcon(Icon.createWithResource(this, R.drawable.ic_dynamic_shortcut_2))
                new Intent[]{
                        new Intent(Intent.ACTION_MAIN, Uri.EMPTY, this, MainActivity.class).setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK),
shortcutManager.setDynamicShortcuts(Arrays.asList(dynamicShortcut, dynamicShortcut));

Create shortcuts, An example of creating a dynamic shortcut and associating it with your app appears in the following code snippet: Note: Instances of the  In this case, use the ShortcutManager API, you can find more about it on the Android Developers website. To recap: STATIC shortcuts don’t require Java code while DYNAMIC ones do. This is the

Perfect Solution for all devices (Pre/Post Oreo device).
createShortcut(CurrentActivity.this, ActivityToOpen.class, "app name", R.mipmap.ic_launcher);

Put this in your Util.

 public static void createShortcut(@NonNull Activity activity, Class activityToOpen, String title, @DrawableRes int icon) {
        Intent shortcutIntent = new Intent(activity, activityToOpen);
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) { // code for adding shortcut on pre oreo device 
            Intent intent = new Intent("");
            intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
            intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, title);
            intent.putExtra("duplicate", false);
            Parcelable parcelable = Intent.ShortcutIconResource.fromContext(activity, icon);
            intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, parcelable);
        } else { 
            ShortcutManager shortcutManager = activity.getSystemService(ShortcutManager.class);
            assert shortcutManager != null;
            if (shortcutManager.isRequestPinShortcutSupported()) {
                ShortcutInfo pinShortcutInfo =
                        new ShortcutInfo.Builder(activity, "browser-shortcut-")
                                .setIcon(Icon.createWithResource(activity, icon))

                shortcutManager.requestPinShortcut(pinShortcutInfo, null);
            } else {

ShortcutManager, Learn how to add shortcuts to specific actions within your app. The types of shortcuts that you create for your app depend on the app's key use cases. by copying your app's static and dynamic shortcuts onto the launcher. that can be performed on shortcuts, see the ShortcutManager API reference. 2) Dynamic shortcuts: Dynamic shortcuts are defined in class (.java) files. So it can change at runtime in the application. To create a dynamic shortcut, ShortcutManager API is used. There are different methods available as below: i) Publish: To publish shortcut,Use setDynamicShortcuts(List) to define list of dynamic shortcuts or use

We should set the shortcut intent to Target Activity rather than mentioning implicit intents.


ShortcutManager shortcutManager = null;
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N_MR1) {
        shortcutManager =  getSystemService(ShortcutManager.class);
        Intent intent= new Intent(this, MainActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
        ShortcutInfo shortcut = new ShortcutInfo.Builder(this, "shortcutId")
                .setIcon(Icon.createWithResource(this, R.drawable.ic_launcher_background))


And Activity in my Manifest.xml is :

    <activity android:name=".MainActivity">
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
             <action android:name="android.intent.action.VIEW" />


Am landing to my MainActivity on clicking the dynamic shortCut which handles Action_VIEW .

App shortcuts overview, launcher screen. Users can use the App Shortcuts feature by long-press on the app icon. app shortcuts. Google has released a major update of 7.1 version (​API 25) with some pretty cool features. One of We will use the ShortcutManager and ShortcutBuilder.Info in order to create dynamic shortcuts. If your app targets Android 7.1 (API level 25) or higher, you can define shortcuts to specific actions in your app. These shortcuts can be displayed in a supported launcher.

Dynamic Shortcuts: ShortcutManager is used to manage all the dynamic Shortcuts. ShortcutInfo represents single shortcut, which will then be added to ShortcutManager via ShortcutInfo.Builder.

   //......................................* Java Dynamic Shortcuts
ShortcutManager shortcutManager = getSystemService(ShortcutManager.class);

Intent thirdIntent = new Intent(this,ThirdActivity.class);

ShortcutInfo thirdScreenShortcut = new ShortcutInfo.Builder(this, "shortcut_third")
 .setShortLabel("Third Activity")
 .setLongLabel("This is long description for Third Activity")
 .setIcon(Icon.createWithResource(this, R.drawable.your_image))

  //......................................*  KOTLIN Dynamic Shortcuts
 val shortcutManager = getSystemService(

            val thirdIntent = Intent(this,
            thirdIntent.action = Intent.ACTION_VIEW

            val dynamicShortcut = ShortcutInfo.Builder(this, "shortcut_third")
                .setShortLabel("Third Activity")
                .setLongLabel("This is long description for Third Activity")
                .setIcon(Icon.createWithResource(this, R.drawable.your_image))

  shortcutManager!!.dynamicShortcuts = listOf(dynamicShortcut)

Key Notes :

How to Implement App Shortcuts in Android 7.1 Nougat?, App shortcuts are new in Android 7.1 and can be seen on Nexus and Pixel The ShortcutManager API was created to dynamically create and  Static App Shortcut Dynamic Shortcuts. The ShortcutManager API allows you to add/update/remove using following operations on dynamic shortcuts:. Publish: Use setDynamicShortcuts(List) to redefine the entire list of dynamic shortcuts, or use addDynamicShortcuts(List) to augment an existing list of dynamic shortcuts.

Android app shortcuts, On the other hand, dynamic shortcuts can be created and destroyed at I've created a sample app in Kotlin called Konstellations the API version every time I used the ShortcutManager, so I wouldn't And with that you should be well on your way to implementing Android 7.1's new feature App Shortcuts! Google has brought Android Nougat to its second iteration with the 7.1 version (API 25). This one is not a minor release - as a matter of fact it bundles some interesting features under the hood. One of these extra features is App Shortcuts. This post explores what they are, how they work, and how you can implement them.

Implementing Android App Shortcuts - Andrew Orobator, Android Nougat 7.1 comes with great feature App Shortcut for both user and developer. The ShortcutManager API allows you to add/update/remove using following Following code snippet will create dynamic shortcut:  Android shortcuts. In Android 7.1 / API 25, Google has introduced a very cool feature called “Android App Shortcuts”. In this article, I will explain how to query and launch Android shortcuts from your application. TL;DR? Here is the source code of the article.

App Shortcuts, a new feature from Android Nougat 7.1, In the latest version of Android, Nougat 7.1 (API 25), Google introduced a new This allows you to create shortcut for specific action or screen in your app that can be Dynamic Shortcut : Dynamic shortcuts should provide links to specific, They are published at runtime using the ShortcutManager API. getDynamicShortcuts. added in API level 25 List getDynamicShortcuts Return all dynamic shortcuts from the caller app. This API is intended to be used for examining what shortcuts are currently published.