Check if the installation source is from the play store

2

Hello, I was thinking of making a PRO version (without advertisement) of my Android App, but I'd like to know how the font verification works, whether it was installed by the play store or You did not buy the app .

Can anyone explain how this process works?

    
asked by anonymous 10.11.2016 / 01:46

2 answers

3

You can use the String getInstallerPackageName(String packageName) method of class PackageManager it will return the package name corresponding to the play store installation package, you just need to pass the current package of your application to it and do the verification

See a small example of how to implement and use the getInstallerPackageName method below:

public boolean isInstalledFromMarket(String pkgName)
        throws NameNotFoundException { 
    String installerPkg = pkgMngr.getInstallerPackageName(pkgName);
    boolean installedFromMarket = "com.google.android.feedback".equals(installerPkg);
    return installedFromMarket;
}

The variable pkgMngr is an instance of class PackageManager , as stated above, and it is required.

Sources: Method documentation getInstallerPackageName
Example of the implementation of the getInstallerPackageName method.

    
11.11.2016 / 01:42
1

If Google Play is the PackageManager.getInstallerPackageName () method, it should return "com.android.vending". Take a look at this

But I think you'll also have to see if the app was purchased. How to secure my app against piracy

    
11.11.2016 / 00:56