为了正常的体验网站,请在浏览器设置里面开启Javascript功能!

创建和删除桌面快捷方式

2017-09-26 2页 doc 13KB 12阅读

用户头像

is_591137

暂无简介

举报
创建和删除桌面快捷方式创建和删除桌面快捷方式 1、创建 /** *为程序创建桌面快捷方式 */ private void addShortcut(){ Intent shortcut = new Intent("com.android.launcher.action.INSTALL_SHORTCUT"); //快捷方式的名称 shortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME,getString(R.string.app_name)); shortcut.putExtra("duplicate"...
创建和删除桌面快捷方式
创建和删除桌面快捷方式 1、创建 /** *为程序创建桌面快捷方式 */ private void addShortcut(){ Intent shortcut = new Intent("com.android.launcher.action.INSTALL_SHORTCUT"); //快捷方式的名称 shortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME,getString(R.string.app_name)); shortcut.putExtra("duplicate",false);//不允许重复创建 //指定当前的Activity为快捷方式启动的对象: //注意: ComponentName的第二个参数必须加上点号(.),否则快捷方式无法启动相应程序 ComponentName comp = new ComponentName(this.getPackageName(), "."+this.getLocalClassName()); shortcut.putExtra(Intent.EXTRA_SHORTCUT_INTENT,new Intent(Intent.ACTION_MAIN).setComponent(comp)); //快捷方式的图标 ShortcutIconResource iconRes= Intent.ShortcutIconResource.fromConte(this,R.drawable.icon); shortcut.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, iconRes); sendBroadcast(shortcut); } 2.删除 /** *删除程序的快捷方式 */ private void delShortcut(){ Intent shortcut = new Intent("com.android.launcher.action.UNINSTALL_SHORTCUT"); //快捷方式的名称 shortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME,getString(R.string.app_name)); //指定当前的Activity为快捷方式启动的对象: 如 com.everest.video.VideoPlayer //注意: ComponentName的第二个参数必须是完整的类名(包名+类名),否则无法删除快 捷方式 String app = this.getPackageName()+"."+this.getLocalClassName(); ComponentName comp = new ComponentName(this.getPackageName(),app); shortcut.putExtra(Intent.EXTRA_SHORTCUT_INTENT,new Intent(Intent.ACTION_MAIN).setComponent(comp)); sendBroadcast(Shortcut); }
/
本文档为【创建和删除桌面快捷方式】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。 本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。 网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。

历史搜索

    清空历史搜索