Android获取apk程序签名信息代码示例

复制代码 代码如下:

这是获取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;
}

返回的签名信息结果为很长的一串数据

你可能感兴趣的:(Android获取apk程序签名信息代码示例)