Adding Shortcut Manager to Android Application

Pratik Chauhan
2 min readSep 22, 2020
Shortcut Header Image

From Android 7.1 Nougat we can define shortcuts to specific actions in your app.
Shortcuts let your users quickly start common or recommended tasks within your app:

Before implementing, let us see how we can use it inside our apps

Uses:

  1. For showing the frequent conversation person
  2. For faster checkout
  3. For an activity that requires frequent interaction to purchase tickets
  4. For highlighting the screen inside you apps that have higher significant- Eg: Sports app stats screen, game details screen, game schedule screen
  5. Inside train apps — To have our frequent route available

And the list goes on…

Constraints:

It works above API 25 so we have to make sure our method which are using the above code has

@TargetApi(25)

And this if-else

if (Build.VERSION.SDK_INT >= 25) {
createShorcut();
}

Types:

Let's see how many types of shortcut are available

Shortcut Manager types

Type1: Static Shortcut

Step 01: Mention this inside your app’s manifest.xml file

Step 02: Create res/xml folder and create a file inside it.

I am creating a shortcuts.xml file

Type 2: Dynamic Shortcut

Step 01: Create a dynamic shortcut by applying this inside your launcher activity class file

Step 02: Call the function in the onCreate() method and run the code

Here is the screenshot of the final result

Screenshot showing Shortcut Menu

If needed you can also disable the shortcut using the following lines

However, if you want to remove all the shortcuts here comes the saviour

Screenshot — All dynamic shortcuts removed

Conclusion:

So we have learned today how this small and simple implementation of shortcut manager API can enhance and improve the user experience.

Github Repo :https://github.com/cpratik711/AppShortcuts

Hope you all learn something new.

{ Keep improving the code inside braces }
Bye 👋😎

--

--

Pratik Chauhan

Self taught Android developer matching the speed of Android advancements thereby integrating into the apps.