Recently Google has brought update to their latest Android system Nougat with the version 7.1 (API 25). It is a major release for Android developers to bundle multiple items under the hood with interesting functionalities. It will simplify user’s experience with a latest feature called “App Shortcuts”.
This post explores what is an App Shortcut and how you can use it with a small example..
What is an App Shortcut?
An App shortcut in Android Nougat is assimilar to 3D touch in iOS and allows display of any app’s most common actions or tasks on the user’s home screen. Users can add/modify/delete shortcuts by a long press on the app icon. It allows you to drag and rearrange app icons and create shortcut for app features in launcher menu. It allows you to publish five shortcuts which can be a combination of ‘Static’ and ‘Dynamic’ shortcuts.
Static App Shortcuts: They are defined the resource file of an app’s APK and remain constant throughout the application.Static shortcuts are immutable which means that you must wait until you update your entire app to change the details of these static shortcuts.
Why use Static App shortcut:
Static shortcuts are used for generic actions of the app that remains persistent until you update your app.
Dynamic App Shortcuts: Dynamic shortcuts are created at runtime of your app. You can publish, update, and remove these shortcuts as you use these applications. It uses ShortcutManager API.
Why use Dynamic App shortcut:
Dynamic shortcuts are used to provide specific actions within your app that could be changed based on user’s interaction within the app.
Implementing App Shortcuts
To create a static shortcut, 1. Add a meta-data tag to your launcher Activity in the manifest and provide the shortcuts resource file.
2. Create a new resource file: res/xml/shortcuts.xml. 3. This is where we will specify all shortcuts that your app can support. 4. Each element contains information about a static shortcut, including its icon, its description labels, and the intents that it launches within the app.
These are very easy steps to implement. However, you may notice that as you press the Back button on your phone, you will be taken to the Home Screen. Now, if you want to to navigate it within your app then we can add multiple intent tags under the shortcut once we previously created.
https://www.knowarth.com/wp-content/uploads/2020/04/playing-the-long-game.png4001140Chintan Shahhttps://www.knowarth.com/wp-content/uploads/2017/01/knowarth-logo.pngChintan Shah2020-04-29 15:19:482020-04-29 17:15:43Playing the Long Game and adapting to change in times of crisis
https://www.knowarth.com/wp-content/uploads/2017/02/SAAS-based-productivity-management-suite.jpg6571920Krupal Khatrihttps://www.knowarth.com/wp-content/uploads/2017/01/knowarth-logo.pngKrupal Khatri2017-02-28 15:19:302017-02-28 16:39:41SAAS based productivity management suite
https://www.knowarth.com/wp-content/uploads/2016/12/Hospital-Management-System-with-Secure-Mobile-Application.jpg6571920KNOWARTH Adminhttps://www.knowarth.com/wp-content/uploads/2017/01/knowarth-logo.pngKNOWARTH Admin2016-12-30 17:41:182017-01-27 22:48:33Hospital Management System with Secure Mobile Application
https://www.knowarth.com/wp-content/uploads/2016/11/Amazon-Web-Services-AWS-to-Open-Stack-Migration.jpg6571920KNOWARTH Adminhttps://www.knowarth.com/wp-content/uploads/2017/01/knowarth-logo.pngKNOWARTH Admin2016-11-22 17:51:202017-01-30 11:46:29Amazon Web Services (AWS) to Open Stack Migration