How to know if an app has been downloaded from Google Play or Amazon?
amazon-appstore, android, google-play, java
Solution
In Code:
final PackageManager packageManager = getPackageManager();
try {
final ApplicationInfo applicationInfo = packageManager.getApplicationInfo(getPackageName(), 0);
if ("com.android.vending".equals(packageManager.getInstallerPackageName(applicationInfo.packageName))) {
// App was installed by Play Store
}
} catch (final NameNotFoundException e) {
e.printStackTrace();
}
"com.android.vending" tells you it came from the Google Play Store. I'm not sure what the Amazon Appstore is, but it should be easy to test using the above code.
Via ADB:
adb shell pm dump "PACKAGE_NAME" | grep "vending"
Example:
adb shell pm dump "com.android.chrome" | grep "vending"
installerPackageName=com.android.vending
Problem
Is there any way to know if an application has been downloaded from Amazon App Store or Google Play Store? I meant within the app itself, of course. I have deployed an app to both sites and I rather like to know from where the customer has downloaded it within the application. I know, I can deploy different applications to each service, but this adds some maintenance work that could be avoided if there were some manner to solve it just with a conditional within the app using the same package.