Adding Shortcut to App Icon

Adding shortcuts to app icon in the launcher feature is added in the Android Nougat 7.1.1.

It is good feature in android. By using this feature we can provide user to access directly to any screen in our app. We can add max 5 shortcuts for the app which includes both static and dynamic shortcuts.

App shortcuts on Nexus 6P

Image: Source from the


Shortcuts are 2 types.

Static shortcuts :

Statics shortcuts we define the in xml/<name of file>.xml and this xml file should be refer from the manifest.xml file in launcher activity. Static shortcuts are can’t be removed dynamically. If we want to remove we have to update the app with removing this shortcuts.


<manifest xmlns:android=""
  <application ... >
    <activity android:name="Main">
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
      <meta-data android:name=""
                 android:resource="@xml/shortcuts" />
<shortcuts xmlns:android="">
      android:targetClass="com.example.myapplication.ComposeActivity" />
    <!-- If your shortcut is associated with multiple intents, include them
         here. The last intent in the list determines what the user sees when
         they launch this shortcut. -->
    <categories android:name="android.shortcut.conversation" />
  <!-- Specify more shortcuts here. -->

Dynamic shortcuts:

Dynamic shortcuts we can add and remove dynamically. Which is more useful when we want to predict more user operations and give those in the shortcut. Like for contacts app we can find which contact user calling more then we can add that contact in the shortcut.

Dynamic shortcuts we can add and remove dynamically.

Dynamic shortcuts we can create using ShortcutManager API. Which provides set of methods for add, set, remove and other features.


ShortcutManager shortcutManager = getSystemService(ShortcutManager.class);

ShortcutInfo shortcut = new ShortcutInfo.Builder(this, "id1")
    .setShortLabel("Web site")
    .setLongLabel("Open the web site")
    .setIcon(Icon.createWithResource(context, R.drawable.icon_website))
    .setIntent(new Intent(Intent.ACTION_VIEW,




Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s