【获取应用图标并转为bitmap适配android10】出门莫恨无人随,书中车马多如簇。这篇文章主要讲述获取应用图标并转为bitmap适配android10相关的知识,希望能为你提供帮助。
/** * 获取图标 bitmap * * @param context * Context.getExternalFilesDir(Environment.DIRECTORY_PICTURES)//android 10存储图片地址 */ public static synchronized Bitmap getBitmap(Context context) { PackageManager packageManager = null; ApplicationInfo applicationInfo = null; try { packageManager = context.getApplicationContext() .getPackageManager(); applicationInfo = packageManager.getApplicationInfo( context.getPackageName(), 0); } catch (PackageManager.NameNotFoundException e) { applicationInfo = null; } Drawable d = packageManager.getApplicationIcon(applicationInfo); //xxx根据自己的情况获取drawableBitmap APKicon; if(d instanceof BitmapDrawable) { APKicon= ((BitmapDrawable)d).getBitmap(); }else{ Bitmap bitmap = Bitmap.createBitmap(d.getIntrinsicWidth(),d.getIntrinsicHeight(), Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); d.setBounds(0, 0, canvas.getWidth(), canvas.getHeight()); d.draw(canvas); APKicon = bitmap; } //BitmapDrawable bd = (BitmapDrawable) d; //Bitmap bm = bd.getBitmap(); return APKicon; }
推荐阅读
- Android中使用AlertDialog实现几种不同的对话框
- VS/Xamarin Android开发Follow Me
- Android系统启动过程分析
- 行业整体实力有待提高千亿体育APP定制大放异彩
- springmvc之RequestMapping注解既可以修饰类也可以修饰方法
- css——设置圆角border-radius值为50%安卓各版本会变形
- Android涓娇鐢–anvas鍜孭aint缁樺埗涓€涓畨鍗撴満鍣ㄤ汉
- Wowza和Amazon Elastic Transcoder的在线视频
- 像2016年一样产生DWG(Teigha for Architecture)