get Installed Package Signatures - Android App

Android examples for App:Package

Description

get Installed Package Signatures

Demo Code


//package com.java2s;
import android.content.Context;

import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.Signature;

import android.util.Log;

public class Main {

    private static Signature[] getInstalledPackageSignatures(
            Context context, String packageName) {
        Signature[] signatures = null;
        PackageManager pm = context.getPackageManager();
        try {/* ww w  . j av  a 2 s  . c  om*/
            signatures = pm.getPackageInfo(packageName,
                    PackageManager.GET_SIGNATURES).signatures;
        } catch (NameNotFoundException e) {
            e.printStackTrace();
        }
        Log.d("aaaa",
                "getInstalledPackageSignatures " + signatures[0].toString());
        return signatures;
    }
}

Related Tutorials