
Android Application Development Cookbook
By :

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.
Here is a screenshot showing our shortcut on the Home screen:
As you can see, this is just a shortcut, but we will explore creating a Home screen (AppWidget) in the next recipe.
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.
The first step is to add the appropriate permission. Here are the steps:
Open the AndroidManifest
file and add the following permission:
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />
Next, open activity_main.xml
and replace the existing TextView with the following button:
<Button android:layout_width...
Change the font size
Change margin width
Change background colour