0
点赞
收藏
分享

微信扫一扫

Android低版本桌面软件快捷键生成


private void createShowcut() {
//需要桌面生成的快捷图标

Intent intent=new Intent();
intent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");

// 告诉桌面 快捷的图片
intent.putExtra(Intent.EXTRA_SHORTCUT_ICON, BitmapFactory.decodeResource(getResources(),R.drawable.a));
//告诉桌面 快捷的名称
intent.putExtra(Intent.EXTRA_SHORTCUT_NAME,"手机卫士");
intent.putExtra("duplicate", false);
// 告诉桌面 快捷图标点击后的事件
Intent intentStart=new Intent();
intentStart.setAction("com.liwangjiang.safeadd");
intentStart.addCategory(Intent.CATEGORY_DEFAULT);

intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT,intentStart);
sendBroadcast(intent);
}

权限

<!--生成桌面快捷键-->
<uses-permission android:name="android.permission.INSTALL_SHORTCUT"></uses-permission>

要打开的Activity

<activity android:name=".activity.HomeActivity">
<intent-filter>
<action android:name="com.liwangjiang.safeadd"></action>
<category android:name="android.intent.category.DEFAULT"></category>
</intent-filter>
</activity>

 

举报

相关推荐

0 条评论