Redeem Now
Read More
Read now

How to create App Shortcuts

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

. . .

Comment

Add Your Comment

Be the first to comment.

css.php
Hire Us!
Brief us about your requirements and we'll get back to you.
Woo! Hooy!
We have just recieved your project brief and our expert will contact you shortly.
Send Again
Close