get Raw Signature - Android android.content.pm

Android examples for android.content.pm:PackageManager

Description

get Raw Signature

Demo Code

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

public class Main {

   static Signature[] getRawSignature(Context context, String packageName) {
    if ((packageName == null) || (packageName.length() == 0)) {
      return null;
    }//from   w  w  w  .  j a v a 2s . c  o m
    PackageManager pkgMgr = context.getPackageManager();
    PackageInfo info = null;
    try {
      info = pkgMgr.getPackageInfo(packageName, PackageManager.GET_SIGNATURES);
    } catch (NameNotFoundException e) {
      return null;
    }
    if (info == null) {
      return null;
    }
    return info.signatures;
  }

}

Related Tutorials