其他分享
首页 > 其他分享> > Android8.0后获取Apk的icon区别

Android8.0后获取Apk的icon区别

作者:互联网

PackageManager packageManager = context.getPackageManager();
ApplicationInfo appInfo = packageManager.getApplicationInfo(packageName, 0);
Drawable icon = appInfo.loadIcon(packageManager);
Bitmap bitmap;
try {
if (Build.VERSION.SDK_INT >= 26 && icon instanceof AdaptiveIconDrawable) {
bitmap = Bitmap.createBitmap(icon.getIntrinsicWidth(), icon.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
icon.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
icon.draw(canvas);
} else {
bitmap = ((BitmapDrawable) icon).getBitmap();
}
} catch (Exception e) {
}

标签:canvas,Canvas,bitmap,Apk,Android8.0,Bitmap,packageManager,icon
来源: https://www.cnblogs.com/mengdao/p/15108149.html