更新时间:2022-11-11 19:18:53
调用 PackageManager.getInstallerPackageName(myPackageName)
,其中 myPackageName
是包的名称(您要确定安装的app)给出了以下值:
空
如果应用程序是从亚马逊应用商店安装空
如果已安装的应用程序的直接的任何应用程序商店的外面。 com.android.vending
如果应用程序是从谷歌安装播放。(感谢@CommonsWare的指针。)
I plan on publishing my app on Amazon app store as well as Google Play, and have some things in my app that need to behave slightly different depending on whether the app was installed from Amazon app store or not. If I understood the PackageManager.getInstallerPackageName(String packageName)
method correctly, it tells me the name of the application that installed my app. Right? If so, does anyone know what the value returned by this method would be if my app was installed from Amazon app store? If not, does anyone know any other methods I can use to determine whether my app was installed from the Amazon app store?
Note: I am aware of other questions on Stack Overflow which have been answered alluding to the usage of
PackageManager.getInstallerPackageName(String packageName)
to determine the name of the application that installed my app. However, searching Stack Overflow and elsewhere, I have not been able to determine what the value returned byPackageManager.getInstallerPackageName(String packageName)
would be in case the app was installed from the Amazon app store.
Calling PackageManager.getInstallerPackageName(myPackageName)
, where myPackageName
is the name of the package (of the app for which you wish to determine the installer) gives the following values:
null
if the app was installed from Amazon app storenull
if the app was installed directly outside of any app store.com.android.vending
if the app was installed from Google Play.(Thanks @CommonsWare for the pointer.)