Androidデスクトップショートカットを追加し、activityを指定します.
1271 ワード
private void addShortcut(Context context,String name) {
Intent addShortcutIntent = new Intent(ACTION_ADD_SHORTCUT);
//
addShortcutIntent.putExtra("duplicate", false);//
// Intent , Intent.EXTRA_SHORTCUT_INTENT value
// , Toast ,
//
// : MIUI ,
//
addShortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, name);
//
addShortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,
Intent.ShortcutIconResource.fromContext(context,
R.drawable.ic_launcher));
//
Intent sIntent = new Intent(Intent.ACTION_MAIN);
sIntent.addCategory(Intent.CATEGORY_LAUNCHER);// action, category ,
sIntent.setClass(this, DakaActivity.class);// Activity
addShortcutIntent
.putExtra(Intent.EXTRA_SHORTCUT_INTENT, sIntent);
//
sendBroadcast(addShortcutIntent);
}
指定activity登録時