trusted by 100,000 expecting mothers

App Shortcuts in Android 7.1 Nougat

Android 7.1 Nougat has come up with a pretty neat feature — App Shortcuts. You can use the shortcuts feature to bring users from the launcher directly to key actions within your app. Users simply long-press your app’s launcher icon to reveal the app’s shortcuts, then tap on a shortcut to jump to the associated action. These shortcuts are a great way to engage users, and they let you surface the functionality of your app even before users launch your app.

Each shortcut references an intent, each of which launches a specific action or task, and you can create a shortcut for any action that you can express as an intent. For example, you can create intents for sending a new text message, making a reservation, playing a video, continuing a game, loading a map location, and much more. So, those of you folks who were trying to make your custom ones by applying hacks, no need to do that any more.

Here is how it looks:

You can publish two different types of shortcuts: Static and Dynamic. You can add and remove dynamic shortcuts at runtime which you won’t be able to do in static ones. Overall, there is a limitation of 5 app shortcuts per application. At PregBuddy we decided to use three static shortcuts for different article categories we have.

Time for some code now :)

So what are we waiting for! Lets change the target api version to 25 and get started.

1. First we need to add meta-data to the main launcher activity

2. In res, we create a xml package and inside that a shortcuts.xml resource

If you look at the above code, we have added 2 intents. The SHORTCUT_FITNESS is the one that will be opened on click of the App Shortcut. Additionally, The MAIN intent would be added to the back stack, so that when back button is pressed it doesn’t go out of the app.

3. Catch the intent in the Fitness Activity and show that article

Do follow the Shortcut Design Guidelines while designing your icon for the shortcuts. Particularly, I found this sketch template given by Roman Nurik to be very helpful. I feel this is very useful feature. Make your most frequent accessed feature a shortcut. Yeah! Let us delight our users with shortcuts. Do let me know if this article helps you by recommending it :) Download our latest app from Play Store and experience App Shortcuts in action.