You can use the method String getInstallerPackageName(String packageName)
class PackageManager
it will return the package name corresponding to the installation package from the play store, you just need to pass the current package from your application to it and do the verification.
See a short example of how to implement and use the method getInstallerPackageName
down 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 the class PackageManager
, as said above, and she is needed.
Sources:
Documentation of the getInstallerPackageName method
Example of the implementation of the getInstallerPackageName method.
You can use the method getInstallerPackageName class
PackageManager
to find out if it came from the play store, you have to check the package for this.– gato
Thanks, that’s what I wanted to know and I’ll study about.
– user41630
@Now I’m the one who asks: why don’t you put an answer?
– ramaral