Android作成アプリケーションショートカット(shortcut)
1110 ワード
Action:
Uses permission:
private static final String EXTRA_SHORTCUT_DUPLICATE = "duplicate";
private static final String ACTION_INSTALL_SHORTCUT = "com.android.launcher.action.INSTALL_SHORTCUT";
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 intent = new Intent();
intent.setComponent(new ComponentName(this.getPackageName(),
".Splash"));
shortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, intent);
shortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource.fromContext(this,
R.drawable.icon));
sendBroadcast(shortcutIntent);
Uses permission:
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT"/>