How to create App Shortcuts

Updated 11 October 2021

Save

App Shortcuts functionality is used to access the particular actions inside your application directly from the launcher icon, you can check the shortcuts by long pressing on your app icon. The user can also pin the shortcut to access the actions quickly.

 

There are different types of shortcuts:

 

Static shortcuts: These are defined in a resource file that is packaged into an APK or app bundle.

Dynamic shortcuts: These shortcuts are applied at runtime using the ShortcutManager API. You can add, update, and remove shortcuts when using the dynamic shortcuts.

Pinned shortcuts (Android 8.0 =API level 26): These are added with the help ShortcutManager API at runtime.

Note: Users can also create pinned shortcuts themselves by copying your app’s static and dynamic shortcuts onto the launcher.

 

limitations of Shortcut

you can add shortcuts up to five times, static and dynamic shortcuts combined at a time on your app.

There is no limit to the number of pinned shortcuts for your application. Even though your app cannot remove pinned shortcuts, it can still disable them.

Note: Although other apps can’t access the metadata within your shortcuts, the launcher itself can access this data. Therefore, these metadata should conceal sensitive user information.

 

Let’s start with the coding part. Let’s start with MainActivity.kt

 

Now adding the Handler class having the button click event methods:

 

NOTE: 

1. Pinned Shortcuts only work in Android 8.0 and above.

2. Before the pinned shortcuts can be used you must have to create at least 1 or more static or dynamic shortcuts.

3. The pinned shortcuts can be added multiple times.

 

The layout code for the main activity.

 

 

For the static shortcuts, we have to create a shortcuts.xml file under the directory of res->xml(create resource directory if not created.)

 

 

String resources used for the application.

 

 

To instantiate the activity and meta-data of shortcuts on the manifest file.

 

 

Finally, the application shortcuts will be shown like this:

 

. . . . . . . . . .

Thank you for reading till now, you can also check our other blogs: Click here and you can also check the official blog for app shortcuts: Click here

author
. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


Be the first to comment.

Start a Project


    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home