/**
*快捷图标可以创建多个,系统的逻辑并不会帮我们检测是否值创建一个,所以我
*们要自己手动判断
*/
boolean isShortCutInstall = PreferenceUtil.getBoolean(this, Constant.KEY_SHORT_CUT , false);
if(isShortCutInstall){
return ;
}
Intent intent = new Intent(); intent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
//文字label
intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, "黑马手机卫士");
//图标
Bitmap icon = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);
intent.putExtra(Intent.EXTRA_SHORTCUT_ICON, icon);
//点击快捷图标,跳转到什么位置
intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, new Intent(this , SplashActivity.class));
intent.putExtras(new Intent(this , SplashActivity.class));
sendBroadcast(intent);
PreferenceUtil.putBoolean(this, Constant.KEY_SHORT_CUT, true);
创建桌面快捷图标
最新推荐文章于 2023-04-25 10:41:16 发布