Here in this blog, we are discussing one of the features of Android Nougat 7.1 that is App Shortcuts. The App shortcuts will allow the users to access primary actions straight from their launcher by long pressing the app icon.

It’s very helpful for the users to access those actions very quickly and complete their tasks at outside of the app without entering into it. Users can also pin these shortcuts to the home screen even for quick navigation.

In this tutorial, I will describe you to create both static and dynamic App shortcuts, for that just follow the things which I am going to explain here. So, are you ready to ride with us? let’s start and keep accelerate your enthusiasm until the end of this tutorial.

Types of Shortcuts

We have 3 types of Shortcuts in the API.

1. Static Shortcuts: These shortcuts are predefined generated from the XML file that you create. These shortcuts are only changeable until updating the new version of the app because they come together with your .apk.

2. Dynamic Shortcuts: The name implies that they are changeable at any time(runtime). They can be created or destroyed at runtime, no need to wait until the new update of the app.

3. Pinned Shortcuts: These are generated completely at runtime, the user can create itself by copying the static or dynamic shortcuts onto the launcher.

we are allowed only to publish 5 shortcuts (combination of static and dynamic shortcuts) at a time for the app and there is no limitation for Pinned shortcuts.

Note: App must have minimum SDK version set to API 25.

Create New Android Project

Follow the sequence of steps to create an AndroidProject.

1. First, open Android Studio on your pc.

2. Go to File menu->New->New Project

3. Application name: AppShortcutsDemo.

4. Company domain: Your package name.

5. Then click on Next button.

6. Minimum SDK: Android 7.1.1 (Nougat).

7. Then again click on the Next button.

8. Choose the Activity type as Empty Activity, afterward click on Next button.

Purpose

The user always loves to use the App Shortcuts because it reduces the number of taps to the user as well as time.

Limitations

1. Only allows us to create 5 App Shortcuts and it is highly recommended to use 4 App shortcuts.

2. Another limitation is the launcher, all the launchers do not support the App Shortcuts yet.

Testing

1. It is the last process that we need to do here to check the results of our work.

2. To test the App Shortcuts please use the device which is running on Android 7.1 version, with the supported launcher.

3. So, let’s run or build the app by clicking the Run buttonor use shift+F10 in Android studio.

4. After running the app first, it will show the app icon as shown above.

5. when we long press on the app icon then it will open the App Shortcuts what we created in the app.

6. In these four, two are dynamic and two are static App Shortcuts.

7. Moreover, if we click on the App shortcuts it will take you to the respective Activity what we described at intent.

8. For suppose if we click on the settings shortcut then it will open the respective activity as shown above.

9. Here what we are seeing in the above image is Pinned Shortcut which is used for quick navigation to the Settings activity.

Conclusion

I hope that you are well enough to work with App Shortcuts in Android after completing this. If you have any queries, please feel free to drop your comments below. Gracias for keeping your enthusiasm to reach the end of this blog.