0
ショートカットを使用してメニューを作成する方法を見つけようとしています。私がしようとした場合、だから、1つのアクティビティAppの複数のショートカット
private void addShortcut() {
//Adding shortcut for MainActivity
//on Home screen
Intent shortcutIntent = new Intent(getApplicationContext(),
MainActivity.class);
shortcutIntent.setAction(Intent.ACTION_MAIN);
Intent addIntent = new Intent();
addIntent
.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
addIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, "HelloWorldShortcut");
addIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,
Intent.ShortcutIconResource.fromContext(getApplicationContext(),
R.drawable.ic_launcher));
addIntent
.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
addIntent.putExtra("duplicate", false); //may it's already there so don't duplicate
getApplicationContext().sendBroadcast(addIntent);
}
:私はこのtopicからこのメソッドを持っ
:
例えば私Activity
負荷fragment
はIntent
に来るデータに依存しますMainActivity
の2つのショートカットを作成するには、「ショートカットがすでに作成されています」というメッセージが表示されます。
ありがとうございます。
下記のリンクがあなたにいくつかの手がかりを与えてくれることを願っています。 [https://stackoverflow.com/questions/11240023/two-launchers-for-a-single-activity](https://stackoverflow.com/questions/11240023/two-launchers-for-a-single-activity) –