This recipe explains how to create a link or create a shortcut for your app on the user's Home screen. So as not to be too obtrusive, it's generally best to make this an option for the user to initiate, such as in the settings.
The following is a screenshot showing our shortcut on the Home screen:
As you can see, this is just a shortcut to your app. The next recipe will go deeper by creating a Home screen (AppWidget).
Create a new project in Android Studio and call it HomeScreenShortcut
. Use the default Phone & Tablet options and select the Empty Activity
option when prompted for the Activity Type.
For an app to create a shortcut, it must have the INSTALL_SHORTCUT
permission. With the appropriate permission, it's a simple matter of calling an intent with your app properties. The following are the steps:
- Open the
AndroidManifest
file and add the following permission:
<uses-permission android:name="com.android.launcher.permission...