get Apk Signatures - Android android.content.pm

Android examples for android.content.pm:Apk Property

Description

get Apk Signatures

Demo Code

import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.Signature;
import android.text.TextUtils;

public class Main{

    public static Signature[] getApkSignatures(Context context,
            String apkPath) {//from  w  w w .jav  a  2  s . c o m
        if (context == null || TextUtils.isEmpty(apkPath)) {
            throw new NullPointerException(
                    "Context is null or apk path is null");
        }
        return context.getPackageManager().getPackageArchiveInfo(apkPath,
                PackageManager.GET_SIGNATURES).signatures;
    }

}

Related Tutorials