1: The create icon is as follows:
Copy codeThe Code is as follows: Intent intent = new Intent ();
Intent. setClass (this, SplashActivity. class );
Intent addShortcut = new Intent (ACTION_ADD_SHORTCUT );
Parcelable icon = Intent. Reset cuticonresource. fromContext (this,
R. drawable. icon );
AddShortcut. putExtra (Intent. EXTRA_SHORTCUT_NAME, getString (R. string. app_name ));
AddShortcut. putExtra (Intent. EXTRA_SHORTCUT_INTENT, intent );
AddShortcut. putExtra ("duplicate", 0 );
AddShortcut. putExtra (Intent. EXTRA_SHORTCUT_ICON_RESOURCE, icon );
SendBroadcast (addShortcut );
2: The delete icon is as follows: Copy codeThe Code is as follows: Intent intent = new Intent ();
Intent. setClass (this, SplashActivity. class );
Intent. setAction ("android. intent. action. MAIN ");
Intent. addCategory ("android. intent. category. LAUNCHER ");
Intent addShortcut = new Intent (ACTION_ADD_SHORTCUT );
Parcelable icon = Intent. Reset cuticonresource. fromContext (this,
R. drawable. icon );
AddShortcut. putExtra (Intent. EXTRA_SHORTCUT_NAME, getString (R. string. app_name ));
AddShortcut. putExtra (Intent. EXTRA_SHORTCUT_INTENT, intent );
AddShortcut. putExtra ("duplicate", 0 );
AddShortcut. putExtra (Intent. EXTRA_SHORTCUT_ICON_RESOURCE, icon );
SendBroadcast (addShortcut );
Intent. setAction ("android. intent. action. MAIN ");
Intent. addCategory ("android. intent. category. LAUNCHER ");
Two filter attributes are required.