Last Updated: August 05, 2019
·
3.186K
· javipacheco

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

3 Responses
Add your response

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 ·