添加快捷方式

<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT"/> 

Intent shortcutIntent = new Intent("com.android.launcher.action.INSTALL_SHORTCUT");

   shortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME,getString(R.string.app_name));

   shortcutIntent.putExtra("duplicate", false);

   Intent intent = new Intent();

   intent.setComponent(new ComponentName(getPackageName(), MainActivity.class.getName()));

   shortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, intent);

   shortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,Intent.ShortcutIconResource.fromContext(this, R.drawable.icon));

   sendBroadcast(shortcutIntent);

原文地址:https://www.cnblogs.com/GnagWang/p/2095583.html