private void installShortCut(){
Intent shortcutIntent = new Intent(".INSTALL_SHORTCUT");
(Intent.EXTRA_SHORTCUT_NAME, getString(.app_name));
// 是否可以有多个快捷方式的副本,参数如果是true就可以生成多个快捷方式,如果是false就不会重复添加
(Intent.EXTRA_SHORTCUT_ICON, generatorContactCountIcon(((BitmapDrawable)(getResources().getDrawable(.ic_launcher))).getBitmap()));
("duplicate", false);
Intent mainIntent = new Intent(Intent.ACTION_MAIN);
(Intent.CATEGORY_LAUNCHER);
// 要删除的应用程序的ComponentName,即应用程序包名+activity的名字
//(new ComponentName((), () + ".MainActivity"));
(this, ());
(Intent.EXTRA_SHORTCUT_INTENT, mainIntent);
//(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, (this, ));
(Intent.EXTRA_SHORTCUT_ICON, generatorContactCountIcon(((BitmapDrawable)(getResources().getDrawable(.ic_launcher))).getBitmap()));
sendBroadcast(shortcutIntent);
}
private Bitmap generatorContactCountIcon(Bitmap icon){
//初始化画布
int iconSize=(int)getResources().getDimension(.app_icon_size);
Bitmap contactIcon=(iconSize, iconSize, Config.ARGB_8888);
Canvas canvas=new Canvas(contactIcon);
//拷贝图片
Paint iconPaint=new Paint();
(true);//防抖动
(true);//用来对Bitmap进行滤波处理,这样,当你选择Drawable时,会有抗锯齿的效果
Rect src=new Rect(0, 0, (), ());
Rect dst=new Rect(0, 0, iconSize, iconSize);
(icon, src, dst, iconPaint);
//在图片上创建一个覆盖的联系人个数
int contacyCount=11;
//启用抗锯齿和使用设备的文本字距
Paint countPaint=new Paint(Paint.ANTI_ALIAS_FLAG|Paint.DEV_KERN_TEXT_FLAG);
();
(20f);
(Typeface.DEFAULT_BOLD);
((contacyCount), iconSize-18, 25, countPaint);
return contactIcon;
}