I know this is probably a longshot, but is there any way to detect programatically whether an app was hosted on the Amazon apps store vs on Google Play? I would like to link to the app store the app was downloaded from, and I'd rather not have two different APKs with just this difference if it can be avoided.
Asked
Active
Viewed 4,521 times
18
-
do apps loaded from amazon get their updates from there...........? – Gung Foo Mar 11 '13 at 21:11
2 Answers
26
As of just recently, the Amazon Appstore returns sane values for PackageManager.getInstallerPackageName()
PackageManager pm = context.getPackageManager();
String installerPackageName = pm.getInstallerPackageName(context.getPackageName());
if ("com.android.vending".equals(installerPackageName)) {
//do google things
} else if ("com.amazon.venezia".equals(installerPackageName)) {
//do amazon things
}
See here: https://forums.developer.amazon.com/forums/thread.jspa?threadID=680
Examples for rate this app links:
Google Play-
market://details?id=PACKAGANAME
Amazon Store
or
amzn://apps/android?p=com.amazon.mp3

arbel03
- 1,217
- 2
- 14
- 24

prestomation
- 7,225
- 3
- 39
- 37
-
-
7Note that getInstallerPackageName() may return null if the app was installed using ADB – Martin Vysny May 19 '14 at 07:35
1
The easiest way is to use different version codes or names between Amazon and Google Play. Then you can use PackageManager.getPackageInfo to retrieve those values and choose the app store link appropriately from there.
Example: suffix all of your Amazon version names with '.65' i.e., 1.0.65. Then use
public boolean isAmazon(Context context) {
String versionName = "";
try {
versionName = context.getPackageManager().getPackageInfo(
getPackageName(), 0).versionName;
} catch (NameNotFoundException e) {
// Can't find itself...
}
return versionName.endsWith(".65");
}

ianhanniballake
- 191,609
- 30
- 470
- 443
-
Thanks. This is one way to do it, but unfortunately it's a compile-time change that doesn't solve the specific case. I could just as easily add a meta-data tag to my manifest, which is probably cleaner in the long run, as versions can remain identical for both packages. – Sky Kelsey Mar 12 '13 at 00:05
-
It's better to use PackageName instead of VersionName because it is weird to add a letter to a version (easier to change the bundle name). – Idan Nov 11 '14 at 07:47
-
1Also Amazon does not accept version name different from x.x.x.x.x where x is only integers. Read it here: [Link](https://developer.amazon.com/public/support/submitting-your-app/tech-docs/submitting-your-app) – ARLabs Jan 09 '15 at 10:29