Android创建快捷方式(shortcut)
创建应用程序的快捷方式如下:
Action
private static final String ACTION_INSTALL_SHORTCUT = "com.android.launcher.action.INSTALL_SHORTCUT";
Intent shortcutIntent = new Intent(ACTION_INSTALL_SHORTCUT);
shortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME,
getString(R.string.app_name));
shortcutIntent.putExtra(EXTRA_SHORTCUT_DUPLICATE, false);
Intent intent = new Intent();
intent.setComponent(new ComponentName(this.getPackageName(),
".Splash"));
shortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, intent);
shortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,
Intent.ShortcutIconResource.fromContext(this,
R.drawable.icon));
sendBroadcast(shortcutIntent);
Uses permission
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT"/>
删除快捷方式试了很久没测试成功过,不知那位同学贡献一下代码?
总结的关于添加和删除及判断是否存在快捷方式,Android应用添加(创建)和删除及判断是否存在桌面快捷方式
没写过你可以试试把Intent加入你想启动的服务。不行,你就写个widget.
老兄,请教一个问题, 给应用程序创建快捷方式时,这个快捷方式的点击事件并不是打开给应用程序,而是执行应用程序里的一个服务,那快捷方式的事件要怎么写呢?直接通过intent不能实现跳转到服务,老是提示“应用程序尚未安装在你的手机上” 如何解决阿???指点下
怎么判断是否已经创建了快捷方式呢
刚再用真机试了一次,能自动删除。
呵呵 那 你这样设置快捷键的以后 当程序卸载后,这些快捷键 是否能自动删除了,我这好像不能 测试过了,不知道你那边怎么样?
你是设置了false?我在模拟器和手机上是可以的哦
这个好像不能 限制重复 在桌面上 创建快捷键吧~~
是否重复,设置为true时,可在HOME界面创建重复的快捷方式。
问下 EXTRA_SHORTCUT_DUPLICATE 这个我找不到是怎么回事