private static final String ACTION_INSTALL_SHORTCUT =
"com.android.launcher.action.INSTALL_SHORTCUT";
/**
* 是否可以有多个快捷方式的副本
*/
static final String EXTRA_SHORTCUT_DUPLICATE = "duplicate";
Intent shortcutIntent = new Intent(ACTION_INSTALL_SHORTCUT);
shortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME,
getString(R.string.app_name));
shortcutIntent.putExtra(EXTRA_SHORTCUT_DUPLICATE, false);
Intent intent2 = new Intent(Intent.ACTION_MAIN);
intent2.addCategory(Intent.CATEGORY_LAUNCHER);
intent2.setComponent(new ComponentName(this.getPackageName(),
".Main"));
shortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, intent2);
shortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,
Intent.ShortcutIconResource.fromContext(this,
R.drawable.icon)); //可以修改icon的值
sendBroadcast(shortcutIntent);
"com.android.launcher.action.INSTALL_SHORTCUT";
/**
* 是否可以有多个快捷方式的副本
*/
static final String EXTRA_SHORTCUT_DUPLICATE = "duplicate";
Intent shortcutIntent = new Intent(ACTION_INSTALL_SHORTCUT);
shortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME,
getString(R.string.app_name));
shortcutIntent.putExtra(EXTRA_SHORTCUT_DUPLICATE, false);
Intent intent2 = new Intent(Intent.ACTION_MAIN);
intent2.addCategory(Intent.CATEGORY_LAUNCHER);
intent2.setComponent(new ComponentName(this.getPackageName(),
".Main"));
shortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, intent2);
shortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,
Intent.ShortcutIconResource.fromContext(this,
R.drawable.icon)); //可以修改icon的值
sendBroadcast(shortcutIntent);