<分区>
Possible Duplicate:
Android create shortcuts on the home screen
我的 Activity (HomeActivity.class) 中有一个 TextView
和 Button
。
目标:当我点击 Button
时,它应该创建一个快捷方式,将默认的 android 图像作为图标,并在 TextView
中输入文本>.
到目前为止,我发现我们可以使用 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);
我的 list 文件:
<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>
但是这段代码并没有创建任何快捷方式。
如何创建快捷方式?