Android and android Official Website
Code
/***** Return the Intent added to the desktop shortcut: ** 1. specify action = "com. android. launcher. INSTALL_SHORTCUT "** 2. define it as Intent. the Intent settings of EXTRA_SHORTCUT_INENT are the same as those during installation (required) ** 3. add permission: com. android. launcher. permission. INSTALL_SHORTCUT */public Intent getshortcuttow.topintent (Context context) {Intent intent = new Intent (); intent. setClass (context, context. getClass ();/* the following two sentences are used to delete the desktop shortcut */intent when you detach an application. setAction ("android. intent. action. MAIN "); intent. addCategory ("android. intent. category. LAUNCHER "); Intent export cut = new Intent (" com. android. launcher. action. INSTALL_SHORTCUT "); // reconstruction of shortcut is not allowed. putExtra ("duplicate", false); // set the name // shortcut. putExtra (Intent. EXTRA_SHORTCUT_NAME, context. getString (R. string. app_name); shortcut cut. putExtra (Intent. EXTRA_SHORTCUT_NAME, "11111"); // sets the shortcut cut icon. putExtra (Intent. EXTRA_SHORTCUT_ICON_RESOURCE, Intent. using cuticonresource. fromContext (context, R. drawable. youtube); // sets intent and shortcut Association program shortcut. putExtra (Intent. EXTRA_SHORTCUT_INTENT, intent); return shortcut ;}
Permission
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT"/>
Call
public void click1(View v) { Intent intent = this.getShortcutToDesktopIntent(MainActivity.this); sendBroadcast(intent); }
I am the dividing line of tiantiao
What is android
Android means a robot. android phones use android phones. Google developed android phones and android phones do not know what the android phones mean.
What is android
Android means a robot. android phones use android phones. Google developed android phones and android phones do not know what the android phones mean.