Invoking apps using keyboard shortcuts 10.3.1

On BlackBerry 10 devices that have physical keyboards (such as the BlackBerry Q10 smartphone and BlackBerry Passport smartphone), users can start apps by using keyboard shortcuts from the home screen or BlackBerry Hub. A keyboard shortcut lets a user press and hold a key to start an app. Several apps are already assigned to keys by default, such as the Settings app (assigned to the O key) and the Phone app (assigned to the P key). If an app isn't assigned to the key that's pressed, the user can choose an app to assign to that key from a list of apps.

There are four types of available shortcuts:

  • App Launch Shortcut
  • Quick Compose Shortcut
  • Speed Dial
  • Other Shortcut

For the App Launch Shortcut type, you don't need to do anything special in your app for it to appear in this list; your app is included automatically. The user can select the App Launch Shortcut menu option and assign your app to the key. When the user presses and holds the shortcut key, your app starts.

Screen shots showing how to assign an App Launch Shortcut to a shortcut key.

Instead of just starting your app, you might want users to be able to create a shortcut to a specific task in your app. For example, if your app allows users to create a new item or entry, you could create a shortcut directly to the creation screen in your app. To do this, you define an invocation target with an action of bb.action.SHORTCUT and a MIME type of application/vnd.blackberry.shortcut. These values let your custom shortcut appear in the Other Shortcut category for the user to select and assign to a key. You can define as many custom shortcuts as you want, each performing a specific task in your app. Don't forget to provide an appropriate label and icon for your shortcut!

Screen shots showing how to assign an Other Shortcut to a shortcut key.

For some shortcut tasks, it doesn't make sense to invoke an app UI to perform the task. For example, for a shortcut that mutes the notification sounds on a device, it isn't necessary to open an app UI when the shortcut key is pressed. To support this behavior, you can use a headless invocation target as a shortcut. If you choose to use this approach, make sure to provide the user with feedback when your headless app finishes the task. You could flash the LED or vibrate the device, or you could consider other notification options such as notification dialog boxes or instant previews.

To learn more about headless apps, including how to create one from scratch, see Headless apps.

You define your invocation target in the bar-descriptor.xml file for your app. Here's an example of a target that defines the "Quick Respond" shortcut for an app:

<invoke-target id= "com.example.EmergencyResponder">
    <invoke-target-name>Quick Respond</invoke-target-name>

When you create filters for shortcuts in your app, it's a good idea to always give the target a meaningful icon and name that describes the task that it performs.

For more information about defining invocation targets, see Target declaration.

Last modified: 2015-03-31

Got questions about leaving a comment? Get answers from our Disqus FAQ.

comments powered by Disqus