可能性の重複:私は私の活動(HomeActivity.class)で1
TextView
とButton
を持っています
Android create shortcuts on the home screen作成ショートカット
。
目標:私はTextView
に入力されたとして、それはアイコンとテキストとしてデフォルトアンドロイドの画像とのショートカットを作成する必要がありButton
をクリックしてください。
はこれまでのところ、私たちはこれは私がこれまで持っているコードがあるACTION_CREATE_SHORTCUT
使用してショートカットを作成できることを発見しました:
Intent result = new Intent(android.content.Intent.ACTION_CREATE_SHORTCUT);
result.putExtra(Intent.EXTRA_SHORTCUT_INTENT,
new Intent(getApplicationContext(), Editor.class));
result.putExtra(TodoDbAdapter.KEY_ROWID,rowid);
result.putExtra(Intent.EXTRA_SHORTCUT_NAME,textView.getText());
result.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,
Intent.ShortcutIconResource.fromContext(HomeActivity.this,
R.drawable.icon));
setResult(RESULT_OK, result);
私のマニフェストファイル:
<activity android:name=".HomeActivity" android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.CREATE_SHORTCUT" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
しかし、このコードはショートカットを作成しません。
ショートカットを作成するにはどうすればよいですか?
私はあなたが[このページ](http://codinggeek.org/2011/を見ているべきだと思います01/02/android-how-to-add-home-screen-あなたのアプリへのショートカット/)それはおそらく[この質問]の複製です(http://stackoverflow.com/questions/5676090/android-is-there-a-programming-way-to-create-a-web-shortcut-on-home-screen )または[この質問](http://stackoverflow.com/questions/6337431/android-create-shortcuts-on-the-home-screen)を参照してください。 –