打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
Android生成快捷方式
避免多次生成快捷方式,存储一个boolean值判断是否已经生成快捷方式,生成快捷方式要添加权限
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT"/>
private void initShorCut() {
//给生成快捷方式的广播对应的意图添加action
Intent intent = new Intent("com.android.launcher.action.INSTALL_SHORTCUT");
//添加快捷方式图标
intent.putExtra(Intent.EXTRA_SHORTCUT_ICON, BitmapFactory.decodeResource(getResources(),R.mipmap.ic_launcher));
//添加快捷方式名称
intent.putExtra(Intent.EXTRA_SHORTCUT_NAME,"星空手机卫士");
//添加快捷方式意图,给开启的activity配置IntentFileter,
Intent jump = new Intent();
jump.setAction("android.intent.action.Home");
jump.addCategory("android.intent.category.DEFAULT");
intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT,jump);

//发送广播隐式意图
sendBroadcast(intent);

SpUtil.writeBool(this,ConstValue.SHORT_CUT,true);
}
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
Android应用自动添加桌面图标
Android添加快捷方式(Shortcut)到手机桌面
安卓代码中创建快捷方式
Android之生成桌面快捷方式(二)
[Android]为指定的应用创建桌面快捷方式
android如何添加桌面图标和卸载程序后自动删除图标
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服