Adding Shortcut Manager to Android Application
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:
- For showing the frequent conversation person
- For faster checkout
- For an activity that requires frequent interaction to purchase tickets
- For highlighting the screen inside you apps that have higher significant- Eg: Sports app stats screen, game details screen, game schedule screen
- 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
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
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
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 👋😎