Java tutorial
//package com.java2s; //License from project: Apache License 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 { /** * Check the signature is modified * * @author : sWX293372 * @version: 1.0 * @return boolean if the signature is modified then return true, else * return false * @createTime : 2016-5-9 */ public static boolean checkSignature(Context context, String packageName, int defaultSig) { boolean isSignatureModified = true; PackageManager pm = context.getPackageManager(); try { PackageInfo pi = pm.getPackageInfo(packageName, PackageManager.GET_SIGNATURES); Signature[] signatures = pi.signatures; int sig = signatures[0].hashCode(); if (defaultSig == sig) { isSignatureModified = false; } } catch (NameNotFoundException e) { e.printStackTrace(); } return isSignatureModified; } }