android 代码创建快捷方式
来源:互联网 发布:excel数据转换到word中 编辑:程序博客网 时间:2024/04/27 06:13
代码如下:
写道
/**
* 创建快捷方式
*/
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);
}
* 创建快捷方式
*/
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" /> * 卸载快捷方式
*/
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);
}
- android 代码创建快捷方式
- Android 创建快捷方式 删除快捷方式
- c#创建快捷方式代码
- Android创建快捷方式,Phonegap创建快捷方式
- Android创建快捷方式(shortcut)
- android创建快捷方式
- android 创建快捷方式
- Android:创建快捷方式
- android 创建桌面快捷方式
- android 创建快捷方式
- android创建任意快捷方式
- Android创建快捷方式
- android 创建快捷方式
- Android--创建快捷方式
- Android 创建桌面快捷方式
- android 创建快捷方式
- Android之创建快捷方式
- android创建桌面快捷方式
- ORACLE 数据库导入与导出
- [C++]指针知识点小结
- DB2如何删除用户的所有表
- 周末季
- windows xp 下 批量重命名文件
- android 代码创建快捷方式
- ubuntu看youku
- 【android基础学习之三】——基础控件Toast,EditText,RadioGroup,RadioButton
- do_generic_file_read()函数
- extjs Ext.Ajax.request 从后台得到 String 字符串 在页面显示器内容
- 内存区划分、内存分配、常量存储区、堆、栈、自由存储区、全局区(c++)(二)
- setuid和setgid
- SQL学习(7)分组查询group by
- pgp key