如何在主屏幕中检测快捷方式 [英] How to detect shortcut in Home screen

查看:80
本文介绍了如何在主屏幕中检测快捷方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序,可让您在主屏幕中创建快捷方式".但是我可以检测快捷方式"是否已经存在,而不必再次创建它. 谢谢.

I have an app that allows you to create "shortcuts" in Home Screen. But can i detect if the "shortcuts" already exist, i didn't have to create it again. Thanks.

推荐答案

我遇到了同样的问题.我认为您不可能告诉它是否存在,但我认为我使用的方法也对您有用.

I was having the same issue. I don't think its possible for you to tell if it's there, but I think what I used will work for you as well.

在添加快捷方式之前,只需将其卸载!

Simply uninstall the shortcut before you add it!

intent.setAction("com.android.launcher.action.UNINSTALL_SHORTCUT");
getApplicationContext().sendBroadcast(intent);

intent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
getApplicationContext().sendBroadcast(intent);

只需确保将以下内容添加到清单文件中即可.

Just make sure you add the following to your manifest file.

<uses-permission android:name="com.android.launcher.permission.UNINSTALL_SHORTCUT"/>    

这篇关于如何在主屏幕中检测快捷方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆