Shortcut: Adding a Shortcut to Home
This tutorial demonstrates how you can add shortcuts on the home screen, and track when shortcuts are added to the home screen.
This feature is supported in mobile applications only.
Warm-up
Become familiar with the Shortcut API basics by learning about:
-
Adding a Shortcut
Add a shortcut to the home screen.
Adding a Shortcut
To add a shortcut to the home screen from your application:
-
To use the functions and data types of the Shortcut API, include the <shortcut_manager.h> header file in your application:
#include <shortcut_manager.h>
-
To add a shortcut, use the shortcut_add_to_home() function:
shortcut_add_to_home("Music Player", LAUNCH_BY_APP, NULL, "/path/to/icon", 1, result_cb, NULL);
To add a shortcut, you have to know the package name and set an icon for the application. The icon parameter can be set to NULL (as above) to add a default icon for the application.
-
To track possible errors, define a callback function:
static int result_cb(int ret, void *data) { if (ret < 0) { // Error handling } else { // No error detected } }