Working with Android 7.1 App Shortcuts

KrishaWeb
5 min readMay 30, 2017

--

App Shortcuts is the newest feature from Android 7.1. When you press the application icon for long, it shows specific action shortcuts that can be launched on supported launchers. For instance, a messaging app can display shortcuts to your recent conversation. A dialer app can show shortcuts to your recently dialed numbers. App Shortcuts allow users to quickly access frequently used actions. Instead of taking the long road to opening an app and navigating to the right spot in the interface, users can make use of app shortcuts.

Image Credit: catinean.com

What are App Shortcuts?

In the wake of announcement of Pixel phone from Google, the phone manufactures revealed certain interesting features. Some apps shortcuts are exclusive to the new handsets while others belong to Android 7.1 (Nougat). App Shortcuts API allows users to quickly access selected functions on the home screen without the need of additional navigation.

Image Credit: androidheadlines.com

Two types of App Shortcuts:

Static: Static app shortcuts are defined statically in a resource file. You cannot change them unless you modify the file and re-deploy the application.

Dynamic: Dynamic app shortcuts are published at runtime. You can update it without the need to re-deploy the application.

Why would you need App Shortcuts?

From technical perspective, App Shortcuts are a quick and effortless way of firing your application’s Intents. For developers this surely is welcome news. Now, they get the opportunity to build and test their application shortcuts without the need of purchasing Google’s Pixel phone.

Long pressing the app icon for a second will activate the shortcuts menu. The menu will be displayed with a quick vibration. Upon releasing the press button, the menu will remain. Dragging it in any direction, the menu will disappear, and the icon moves with the drag. This works with icons sitting anywhere in the launcher, in the folders, from the app drawer, or sitting out in the open.

To activate the described function or navigate to the screen, simply tap the menu items. Perhaps, you want to long-press on the shortcut to drag it around in the launcher for greater convenience. It allows you to quick start music, compose messages, or open Map navigation mode.

Thus, you can create shortcuts in Google Messenger of people’s name whom you recently send messages. It allows you to create permanent shortcuts on the home screen for one-tap access.

App Shortcuts Overview with its types

Today approximately 20 apps are offering shortcuts to users. Naturally, all these are from Google. By looking around, one can come across the genuinely useful ones from the available options. Recently API 25 SDK became available for developers. Related apps are already available for download on Google Play. In the coming times, one can expect presence of multiple apps with shortcuts. Pixel Launcher and Now Launcher from Google will offer support for app shortcuts only on android versions 7.1 and above.

App shortcuts are of mainly two types namely:

A. Static Shortcuts: Defined statically within the resource file it is not possible to change static shortcuts including their ranks. The order will be the way you define them initially in the shortcuts.xml file. To change, you have to redeploy app or modify the complete file. Adding the shortcuts to the apps is quite easy. Since you have to add them first, they will always come at bottom.

Shortcut definition in xml:

<shortcuts xmlns:android="...">
<shortcut
android:shortcutId="my_shortcut"
android:enabled="true"
android:icon="@drawable/icon"
android:shortcutShortLabel="@string/shortcut_short_label"
android:shortcutLongLabel="@string/shortcut_long_label"
android:shortcutDisabledMessage="@string/disabled_message">
<intent
android:action="android.intent.action.VIEW"
android:targetPackage="com.example.myapplication"
android:targetClass="com.example.Activity" />
<categories android:name="android.shortcut.conversation" />
</shortcut>
<!-- ... -->
</shortcuts>

Set the shortcuts for an Activity:

<activity android:name="Main">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<!-- Set the shortcuts -->
<meta-data android:name="android.app.shortcuts"
android:resource="@xml/shortcuts" />
</activity>

B. Dynamic Shortcuts: You have to publish these shortcuts during runtime. For updating, redeploying apps is not a requirement. Developers do not have to define them via static resources. For creating them, one has to use codes. By setting custom ranks for dynamic shortcuts, it is possible to control their appearance order. Higher ranks signify top positions for the shortcut. You can change them whenever needed.

ShortcutInfo shortcut = new ShortcutInfo.Builder(context, “id1”)
.setShortLabel(“Web site”)
.setLongLabel(“Open the web site”)
.setIcon(Icon.createWithResource(context, R.drawable.icon_website))
.setIntent(new Intent(Intent.ACTION_VIEW,
Uri.parse(“https://www.mysite.example.com/")))
.build();
shortcutManager.setDynamicShortcuts(Arrays.asList(shortcut));

By exposing the common tasks, you make it easy for users to return to specific app parts. It no longer requires additional navigation.

Here are some shortcuts we’ve spotted so far:

· New contact in Phone (dialler)

· Messenger (SMS)

· Dynamically generated contacts last used in New conversation

· New incognito tab and New Tab in Chrome

· Compose in Gmail

· ‘Free up Space’ and ‘I am Feeling Lucky’ in Photos

· Start Stopwatch and Screen Saver, Create Alarm and Timer (New) in Clock

· Upload, Search, and Scan in Drive

· Navigate to set locations in Maps

· Wi-Fi, Battery, and Data Usage in Settings

· Selfie and Video taking in Camera

· Search, Trending, and Subscription in YouTube

· Add Contacts in Contact

· Shop, My Library in Play Books

· I am feeling lucky, Recent Activity, and My Library in Play Music

Several Google apps like Play Store application, Hangouts, Translate, and Google Plus do not provide shortcuts, yet. It will not be long before it happens though, by all indications.

Still in the initial phases, App Shortcuts might seem genuinely overwhelming to the uninitiated. Once custom android app development embrace this fully, adopt, and explore creative ways of using them, users will get some real values. One can also use this feature in combination with sensitive force screen. This might be the android’s way of finally catching up with the iOS capabilities.

What are your thoughts in this regard? Do not forget to share them with us.

--

--

KrishaWeb
KrishaWeb

Written by KrishaWeb

A Full-Service Digital Agency offering Web Design, UI UX Design, Open Source Development, Framework Development, and Digital Marketing to global clients.

No responses yet