Possible Duplicate:
Android create shortcuts on the home screen
I am having one TextView
and Button
in my Activity (HomeActivity.class).
Goal: When I click on the Button
it should create a shortcut with the default android image as icon and text as entered in the TextView
.
So far I've found out that we can create shortcuts using ACTION_CREATE_SHORTCUT
This is the code I have so far:
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);
My Manifest File :
<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>
But this code does not create any shortcut.
How can I create shortcuts?