代码如下:
写道
/**
* 创建快捷方式
*/
private void createShortCut() {
Intent shortcut = new Intent("com.android.launcher.action.INSTALL_SHORTCUT");
shortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME, "创建快捷方式");
shortcut.putExtra("duplicate", false); // 不允许重复
ShortcutIconResource iconRes = Intent.ShortcutIconResource.fromContext(this,R.drawable.icon);// 设置快捷方式的图标
shortcut.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, iconRes);
// 定义shortcut点击事件
String action = "com.android.action.test";
Intent respondIntent = new Intent(this, this.getClass());
respondIntent.setAction(action);
shortcut.putExtra(Intent.EXTRA_SHORTCUT_INTENT, respondIntent);
sendBroadcast(shortcut);
}
需要权限:<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />
卸载快捷方式:
写道
/**
* 卸载快捷方式
*/
void deleteShortcut() {
Intent shortcut = new Intent("com.android.launcher.action.UNINSTALL_SHORTCUT");
shortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME, "卸载快捷方式"); //指定要卸载的快捷方式的名称
String action = "com.android.action.test";
String appClass = this.getPackageName() + "." + this.getLocalClassName();
ComponentName comp = new ComponentName(this.getPackageName(), appClass);
shortcut.putExtra(Intent.EXTRA_SHORTCUT_INTENT, new Intent(action).setComponent(comp));
sendBroadcast(shortcut);
}
需要权限:<uses-permission android:name="com.android.launcher.permission.UNINSTALL_SHORTCUT" />
分享到:
相关推荐
Android判断是否获取到桌面快捷方式权限
android 检查是否创建桌面快捷方式以及创建快捷方式
仿照微信或是淘宝网,发送快捷方式到桌面,主要代码如下: // 安装的Intent Intent shortcut = new Intent("com.android.launcher.action.INSTALL_SHORTCUT"); // 快捷名称 shortcut.putExtra(Intent.EXTRA...
Android 桌面快捷方式: 创建和删除
android创建桌面快捷方式指向PDF文件
android向桌面添加快捷方式的源代码,将解可以看我的博客哈。
判断快捷方式是否存在,创建和删除桌面快捷方式,支持android5.1以上版本
里面的工具类是 通过 各自的实现来判断 华为,小米 oppo vivi等的应用是否 拥有快捷方式 的权限,如果没有的话,则需要去手动授权。
1.解锁2次,第三次黑屏的时候在桌面上创建一个快捷方式。每一个小时删除快捷方式一次,并创建一次。 2.点击这个快捷方式,跳转到腾讯主页或者百度主页。跳转的时候传入今天日期参数,格式:2014-2-27 3.这个图片从...
类似QQ添加桌面快捷方式联系人,也可以自定义桌面图标,新手值得看看
安装后,可以对系统所有应用在桌面天机哎快捷方式,github上找的源码
概述 :创建桌面快捷方式相当与创建一个程序的入口,就像我们程序在安装完毕后会自动创建一个图标到桌面。其实创建桌面快捷方式跟创建一个程序入口差不多,但是像QQ会话一样创建一个QQ好友的会话快捷方式,就得动态...
Android高级应用源码-创建桌面快捷方式源代码.zip
创建桌面快捷方式源代码(android),作为app开发参考用。
NULL 博文链接:https://justsee.iteye.com/blog/1115247
android中在桌面上创建快捷方式源码,删除快捷方式在某些机器上会不成功,因此最好只添加不删除
可以实现为手机上的某个应用添加桌面快捷方式、移除某个应用到快捷方式 如有问题,请浏览我的博客:http://blog.csdn.net/u011268102/article/details/9335971
本项目是一个在安卓手机桌面上创建和删除快捷方式的例子源码,在我的2.3.7摩托罗拉上测试的可以用,不过在红米上测试的不能用,可以是因为米柚对安卓原生修改的东西太多了吧,需要的朋友下载再自己研究下吧,更为...
Android Launcher 桌面分页滑动代码,安卓桌面应用EyeRoom,创建桌面快捷方式,Android Launcher 源码修改可编译源代码