In my Android app I wanted to check the source of app installation. I looked at the Android documentation and found the following API as part of the PackageManager class:
I tested this API method with both emulator and real devices.
Most of the time, it returns null. Only return com.android.vending
when the app is installed from official Google Play.
With China local app market apps, such as AppChina and wandoujia, null
is returned.
Code snippet and log is posted here: Github Gist
if you want to test this the way is to store the apk on the device by using the
adb push 'test.apk' '/sdcard/Download'
then go to the adb shell by typing in 'adb shell' and hitting enter in the terminal then install using the following command
pm install -i 'installernameyouwant' /sdcard/Download/test.apk
when installing the app in above method the call to getInstallerPackageName() returns the installer name you gave in the above command
credits to @mattmook for the "pm install" command.
With regard to your question how was the app installed onto the device? Through "adb install" it will be null.
Using the following you should be able to override it to whatever you want for testing purposes.
pm install -i installername com.example.package
GooglePlay should have a value of com.google.android.feedback. I'm not sure what values other app stores use.