{"appName":"HBuilder",
"packageName":"io.dcloud.HBuilder",
"versionName":"9.6.34",
"versionCode":90634,
"appIcon":{"UUID":"Invocation61044392","TYPE":"JSBObject","className":"android.graphics.drawable.BitmapDrawable"}
}
这是现在获取到的某个app的详情,我想请问下。这个appIcon 中的值,如何去转化成可读取的图标呢?
- 发布:2019-10-28 19:12
- 更新:2021-11-26 14:59
- 阅读:1888
4***@qq.com (作者)
已找到方法,现在分享下
var ApplicationInfo = plus.android.importClass('android.content.pm.ApplicationInfo');
var MainActivity = plus.android.runtimeMainActivity();
var PackageManager = MainActivity.getPackageManager();
var pinfo = plus.android.invoke(PackageManager, 'getInstalledPackages', 0)
if (pinfo != null) {
var apklist = []
for (var i = 0; i < pinfo.size(); i++) {
//PackageInfo{4b45699f9d com.tencent.mobileqq}
var pkginfo = pinfo.get(i);
var issysapk = ((pkginfo.plusGetAttribute("applicationInfo").plusGetAttribute("flags") & ApplicationInfo.FLAG_SYSTEM) != 0) ? true : false
if(issysapk == false){
const apkinfo = {
appName:pkginfo.plusGetAttribute("applicationInfo").loadLabel(PackageManager).toString(), //应用名称
appIco:pkginfo.plusGetAttribute("applicationInfo").loadIcon(PackageManager),
packageName:pkginfo.plusGetAttribute("packageName"), // 包名
versionName:pkginfo.plusGetAttribute("versionName"), //版本号
versionCode:pkginfo.plusGetAttribute("versionCode")// 版本Code
}
var bimp=apkinfo.appIco.getBitmap();
//console.log("当前bitmap:"+bimp);
var BitmapFactory = plus.android.importClass("android.graphics.BitmapFactory");
var Base64 = plus.android.importClass("android.util.Base64");
var Bitmap = plus.android.importClass('android.graphics.Bitmap');
var ByteArrayOutputStream = plus.android.importClass("java.io.ByteArrayOutputStream");
try{
var baos = new ByteArrayOutputStream();
bimp.compress(Bitmap.CompressFormat.JPEG, 100, baos);
baos.flush();
baos.close();
var bitmapBytes = baos.toByteArray();
var result = Base64.encodeToString(bitmapBytes, Base64.DEFAULT);
document.getElementById("showImg").src="data:image/jpeg;base64,"+result;
}
catch(e){
console.log(e);
}
apklist.push(apkinfo);
}
}
6***@qq.com
app 模式下,图片不显示是什么原因呢
2020-08-01 00:40
zzhi_bo
回复 6***@qq.com: getBitmap 这个是怎么来的呀
2021-11-26 15:11