| 注册
请输入搜索内容

热门搜索

Java Linux MySQL PHP JavaScript Hibernate jQuery Nginx
jopen
9年前发布

获取apk文件的签名信息(未安装, 只是一个apk文件)

    /**        * 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;        }