I am currently developing RPC services for developers to use, but would like to make sure that I can distinguish between another app\'s debug key and their public key. Is there
static final String DEBUGKEY =
" key ";
public static boolean signedWithDebugKey(Context context, Class> cls)
{
boolean result = false;
try {
PackageInfo pinfo = context.getPackageManager().getPackageInfo("your package name",PackageManager.GET_SIGNATURES);
Signature sigs[] = pinfo.signatures;
Log.d(TAG,sigs[0].toCharsString());
if (DEBUGKEY.equals(sigs[0].toCharsString())) {
result = true;
Log.d(TAG,"package has been signed with the debug key");
} else {
Log.d(TAG,"package signed with a key other than the debug key");
}
} catch (android.content.pm.PackageManager.NameNotFoundException e) {
return false;
}
return result;
}
Run this code first time with debugkey, this will alway return false, but you'll get the encoded key in the Logcat. Copy that encoded key, and replace value " key " of DEBUGKEY, and it will work fine.