/** * get signature of an apk file * this method will execute quit a long time, so it is suitable to call it in sub thread * @param context * @param apkFilePath * @return signature , null if there is no signature , or apkFilePath is wrong */ public static String getSignatureOfApk(Context context, String apkFilePath){ Log.i(TAG, "SignatureUtils.getSignatureOfApk"); if (TextUtils.isEmpty(apkFilePath)) return null; PackageManager pm = context.getPackageManager(); PackageInfo pi = pm.getPackageArchiveInfo(apkFilePath, PackageManager.GET_SIGNATURES); Signature[] signatures = pi.signatures; if(signatures != null && signatures.length > 0){ String signature = signatures[0].toCharsString(); Log.i(TAG, "Signature of " + apkFilePath + " is : " + signature); return signature; } return null; }