"ホーム画面に追加" にある "ショートカット" にリストアップされる「ショートカットのアプリ作成方法」を簡単にまとめます。
AndroidManifest
actionをショートカット特有のモノにすればショートカット一覧に並びます。
<activity android:name=".ShortcutActivity" > <intent-filter> <action android:name="android.intent.action.CREATE_SHORTCUT" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </activity>
Activity
ショートカットの中身はIntentなのでIntentを作成することになるのですが、やり方は若干ややこしいです。
// ショートカット作成 Intent shortcutIntent = new Intent("ショートカット先"); // 作成したショートカットを設定するIntent。ここでショートカット名とアイコンも設定。 Intent intent = new Intent(); intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent); intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, R.drawable.icon); intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, "hogehoge"); // ショートカット設定 setResult(RESULT_OK, intent);
これでHome上にショートカットが作成されます。