Check if an APK is from Google Play
With this method you can check if an APK was installed from Google Play
private boolean isFromGooglePlay(String pName) {
PackageManager packageManager = this.getPackageManager();
String installPM = packageManager.getInstallerPackageName(pName);
if ( installPM == null ) {
// Definitely not from Google Play
return false;
} else if ( installPM.equals("com.google.android.feedback") ) {
// Installed from the Google Play
return true;
}
return false;
}
More information: http://androidcracking.blogspot.com.es/2011/01/anti-cracking-example.html
Written by Javi Pacheco
Related protips
3 Responses
I thought this was more difficult and it was necessary to use the Android Licensing Library:
http://developer.android.com/guide/google/play/licensing/index.html
Good tip!
over 1 year ago
·
Cool!, this tip will be very useful for the new version of 'My App List'.
Thanks!
over 1 year ago
·
Javi in my Asus Transformer, the returned InstallerPackageName is "com.android.vending". I had to add:
else if (installPM.equals("com.android.vending") ) {
return true;
}
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Android
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#