【发布时间】:2012-07-11 18:40:57
【问题描述】:
如您所知,当您长按主屏幕时,手机会显示一个列表菜单。 您可以添加快捷方式、小部件、文件夹等。我希望我的应用出现在快捷方式列表中。
我该怎么做?
【问题讨论】:
标签: android shortcut homescreen
如您所知,当您长按主屏幕时,手机会显示一个列表菜单。 您可以添加快捷方式、小部件、文件夹等。我希望我的应用出现在快捷方式列表中。
我该怎么做?
【问题讨论】:
标签: android shortcut homescreen
快捷方式从 API 级别 1 开始就已经存在,并且也可供 3rd 方应用使用。
要将活动添加到快捷方式菜单,只需将此意图过滤器添加到清单中的活动:
<intent-filter>
<action android:name="android.intent.action.CREATE_SHORTCUT" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
要使活动在主屏幕上植入一个带有意图的新图标,请在完成之前执行以下操作:
Intent intent = new Intent();
Intent launchApp = new Intent();
intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, launchApp);
intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, "My shortcut");
intent.putExtra(Intent.EXTRA_SHORTCUT_ICON, myIcon);
setResult(RESULT_OK, intent);
将launchApp Intent 更改为单击它时要启动的任何内容。
请看这里:http://developer.android.com/reference/android/content/Intent.html#ACTION_CREATE_SHORTCUT
【讨论】:
默认情况下该功能已经存在,他们只需从“应用程序”列表中进行选择。您不能直接添加到主快捷方式列表(它会很快变得过于混乱),这是由操作系统提供的,据我所知,第三方应用程序无法填充。
【讨论】: