快捷方式的添加与删除
来源:互联网 发布:Ubuntu设置软件源 编辑:程序博客网 时间:2024/05/22 11:31
快捷方式的添加与删除都是通过广播来实现
添加快捷方式:
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(),".XxxActivity"));//设置要激活的Activity
shortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, intent);//点击快捷方式后发送一个Intent
shortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource.fromContext(this, R.drawable.icon));
sendBroadcast(shortcutIntent);
权限:
<uses-permission
android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />
删除快捷方式:
Intent intent = new Intent(DELETE_ACTION);
intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, "Sample");
ComponentName comp = new ComponentName("com.example.android.apis","com.example.android.apis.app.LauncherShortcuts");
intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, new Intent().setComponent(comp).setAction("android.intent.action.MAIN"));
sendBroadcast(intent);
权限:
<uses-permission
android:name="com.android.launcher.permission.UNINSTALL_SHORTCUT" />
- 快捷方式的添加与删除
- Android代码添加快捷方式与删除快捷方式
- 快捷方式的创建与删除
- android添加删除快捷方式
- MFC添加快捷方式和删除快捷方式
- android桌面快捷方式的创建与删除
- Android 桌面快捷方式的创建与删除
- android 添加和删除快捷方式
- android添加删除桌面快捷方式
- Android 添加和删除快捷方式
- 【Android】添加删除桌面快捷方式
- android添加删除桌面快捷方式
- Android 添加删除应用快捷方式
- Android应用程序添加、删除快捷方式
- 创建与删除快捷方式
- 创建与删除快捷方式
- 删除快捷方式的箭头
- 删除桌面上的快捷方式
- ADT插件的安装方法
- Hdu 3927 反幻方
- 微软笔试题(看到的写答案啊)
- UiTableView相关文章
- python手记(36)
- 快捷方式的添加与删除
- Unity3D精简版网络游戏雏形(简单网络通信聊天和角色监视案例)
- jQuery UI调用draggable之后无法拖拽的解决办法
- Linux Kernel 之AP读写Nand Flash上的Yaffs2文件的全过程浅析
- POJ 1077 HDU 1043 Eight (IDA*)
- hdu - 1757 - A Simple Math Problem(矩阵快速幂)
- xp+ubuntu8.10双系统启动顺序修改
- 最小角回归(Least Angle Regression)
- Python之lxml