Preview Effect Chart:
Permissions Required:
Configuration file: Androidmanifest.xml
<activity
android:name= "com.myself.news.activity.GuideActivity"
android:label= "@string/title_ Activity_guide ">
<intent-filter>
<action android:name=" Com.myself.news.ACTION_HOME "/>
<category android:name= "Android.intent.category.DEFAULT"/>
</intent-filter>
In the application of the splash screen page The activity of the OnCreate method calls the Installshortcut ();
Code:
Create Shortcut
//Com.android.launcher.permission.INSTALL_SHORTCUT
private void Installshortcut () {
// To determine if a shortcut has been created
boolean iscreated = Sharedpreferencesutils.getboolean (this,
Globalconstantsutils.pref_is_ Shortcut_intalled, false);
Determine if the
if (!iscreated) {
//broadcast
Intent Intent = new Intent ()
has been created. Intent.setaction ("Com.android.launcher.action.INSTALL_SHORTCUT");
Icon
///Generate bitmap object based on resource file ID
intent.putextra (intent.extra_shortcut_icon, Bitmapfactory
. Decoderesource (Getresources (), r.drawable.ic_launcher));
Name
Intent.putextra (Intent.extra_shortcut_name, "mobile security Guardian");
Action
Intent actionintent = new Intent ();
Skip to homepage
actionintent.setaction (globalconstantsutils.action_home);
Intent.putextra (Intent.extra_shortcut_intent, actionintent);
Sendbroadcast (intent);
The tag has already created the shortcut, and the next time you no longer create
Sharedpreferencesutils.setboolean (this,
globalconstantsutils.pref_is_shortcut_ Intalled, True);
}
Constant Tool class Globalconstantsutils:
public static final String pref_is_shortcut_intalled = "is_shortcut_intalled";/whether a shortcut has been created public
static final String action_home = "Com.myself.news.ACTION_HOME";//Jump to ACTION on main page