I've made an app which has pro features locked and you must buy the pro version key unlocker on play store to unlock them. Also, the main free app is not available on play store. Actually I've made a Boolean to check if the unlocker app with the package name stated in PACKAGE_NAME
was downloaded from play store.
The problem is that this Boolean always returns false and so also if I've bought the pro key unlocker apk on play store, it always prompts that the app is not genuine. Can anyone tell me why?
Here is the Boolean code:
public boolean isValid() {
PackageManager pm = this.getPackageManager();
String installPM = pm.getInstallerPackageName(PACKAGE_NAME);
if ( installPM == null ) {
// Definitely not installed from Android Market
return false;
}
else if ( installPM.equals("com.google.android.feedback") ) {
// Installed from the Android Market
return true;
}
return false;
}
Here is the if statement checker:
if(isPro()) {
if (!isValid()) {
Log.d(TAG, "This is an hack!");
isHacked();
}
}
Edit: As stated in comments, for me the problem is that PackageManager pm = this.getPackageManager();
refers to the main free app (which contains the activity where I'm using this Boolean) and not at the external application unlocker which has another package name of course. So as the free app is not available on play store it always returns null... but how can I make PackageManager pm = this.getPackageManager();
to refer at another package name?