当前位置: 编程技术>移动开发
Android获取apk程序签名信息代码示例
来源: 互联网 发布时间:2014-10-22
本文导语: 代码如下:这是获取apk包的签名信息private String getSign(Context context) { PackageManager pm = context.getPackageManager(); List apps = pm.getInstalledPackages(PackageManager.GET_SIGNATURES); Iterator iter = apps.iterator(); while(iter.hasNext()) { PackageInfo pac...
代码如下:
这是获取apk包的签名信息
private String getSign(Context context) {
PackageManager pm = context.getPackageManager();
List apps = pm.getInstalledPackages(PackageManager.GET_SIGNATURES);
Iterator 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;
}
返回的签名信息结果为很长的一串数据