You are trying to determine whether your own app has been installed from the Amazon store, so the following pertains to that situation. But things have changed since you asked the question, so this answer is valid for 2016 when it was posted, not 2012.
As reported above, apps installed by versions of the Amazon installer released before about the middle of 2013 return null from getInstallerPackageName() when that method is passed the package name of the installed app. But after that time they started to return "com.amazon.venezia" for such a call. And recently, the Amazon Underground app may assign a second installer package name, com.amazon.mshop.android.
So, this is not a completely reliable indicator if you think you might encounter those older versions of the installer in the wild, because an app that is simply sideloaded (installed from a APK held in local storage) will also typically return null from getInstallerPackageName() when that method is called for its package, and thus will be indistinguishable from an app installed by one of those older Amazon store apps.
If, despite this problem, you want to use this approach, but would like to avoid false negatives for devices having the older installer versions that mark the installer as null, you might try the following:
Test getInstallerPackageName() to see if it is non-null.
If non-null, then just test to see if it starts with com.amazon, and you can believe that it was installed from Amazon if it does, and you can believe that it was not installed from Amazon if it does not.
But if null, do an additional test by iterating over every package on the device, feeding each package name encountered to getInstallerPackageName(), looking to see if there is even a single one that starts with "com.amazon".
If there are none with that value, then your null value is ambiguous, and you should consider that you do not have any information one way or the other regarding whether your app was installed from the Amazon store (as opposed to side-loaded).
But if there is even a single app having that installer package value, then you can assume that your app was not installed from the Amazon store, because it is a safe bet that the device is running a version of the Amazon store that tags installed apps with an installer package name starting with "com.amazon", given that at least one app other than yours was actually tagged that way - which is extremely unlikely to happen in any other way. And that means that the null value for your app was not created by the Amazon installer, but rather, by some other installer - and most probably it means that you app was side-loaded from a local copy of your APK.
uk.amazon.mShop.android
, which is the package name ofAmazon Mobile for Android
on Google Play?... – CresolgetInstallerPackageName()
to see what shows up. My guess is that this will be the same any app installed by any other means. – Induline