Możliwe duplikaty:
Android create shortcuts on the home screentworzenia skrótów w Androidzie przez intencyjny
Mam jedną TextView
i Button
w mojej działalności (HomeActivity.class).
bramki: Kiedy klikam na Button
należy utworzyć skrót z domyślną android obrazu jako ikony i tekst wpisanej do TextView
.
Jak dotąd okazało się, że możemy tworzyć skróty użyciu ACTION_CREATE_SHORTCUT
Jest to kod mam tak daleko:
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);
Mój plik manifestu:
<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>
Ale ten kod nie tworzy żadnego skrótu.
Jak mogę utworzyć skróty?
Myślę, że należy spojrzeć na tej stronie [] (http://codinggeek.org/2011/ 01/02/android-how-to-add-home-screen-skróty-do-twojej-aplikacji /). Jest to prawdopodobnie również duplikat tego pytania (http://stackoverflow.com/questions/5676090/android-is-there-- programming-way-to-create-a-web-shortcut-on-home-screen) lub [to pytanie] (http://stackoverflow.com/questions/6337431/android-create-shortcuts-on-the-home-screen). –