Android获取apk程序签名信息代码示例
程序员文章站
2022-07-11 19:35:17
复制代码 代码如下:这是获取apk包的签名信息private string getsign(context context) { packagemanager...
复制代码 代码如下:
这是获取apk包的签名信息
private string getsign(context context) {
packagemanager pm = context.getpackagemanager();
list<packageinfo> apps = pm.getinstalledpackages(packagemanager.get_signatures);
iterator<packageinfo> iter = apps.iterator();
while(iter.hasnext()) {
packageinfo packageinfo = iter.next();
string packagename = packageinfo.packagename;
return packageinfo.signatures[0].tocharsstring();
if (packagename.equals(instance.getpackagename())) {
mediaapplication.logd(downloadapk.class, packageinfo.signatures[0].tocharsstring());
return packageinfo.signatures[0].tocharsstring();
}
}
return null;
}
返回的签名信息结果为很长的一串数据