简体   繁体   English

如何在Android设备中使用googlePlay检查已安装的应用程序

[英]How to check installed application using googlePlay or not in android device

如何检查是否已从Google Play商店(单击“安装”按钮)或下载的.apk文件安装了任何android应用程序并将其安装在设备中?

When installed from Google Play, you will receive a com.android.vending.INSTALL_REFERRER broadcast during the install process. 从Google Play安装后,您会在安装过程中收到com.android.vending.INSTALL_REFERRER广播。 Simply create a broadcast receiver for this, and have a boolean value in your SharedPreferences along the lines of fromGooglePlay , which you can set to true in the receiver. 只需为此创建一个广播接收器 ,并在fromGooglePlay的行中的SharedPreferences具有一个布尔值,您可以在接收器fromGooglePlay其设置为true。

However, I do not think you can have similar receivers for other app stores, like Amazon's. 但是,我认为您无法为其他应用程序商店(如亚马逊)提供类似的接收器。

Additionally, this will not work on Android 3.1 and above, as apps that have not been launched at least once are not eligible to receive broadcasts. 此外,这在Android 3.1及更高版本上将不起作用,因为尚未启动至少一次的应用程序没有资格接收广播。

However, you can try an alternate solution: 但是,您可以尝试其他解决方案:

In you app, have a constant boolean somewhere, something like GOOGLE_PLAY_BUILD . 在您的应用中,某处有一个常量布尔值,例如GOOGLE_PLAY_BUILD When building an apk for Google Play, set this to true , and when building an apk for manual distribution, set this to false . 为Google Play构建apk时,请将其设置为true ;为进行手动分发而构建apk时,请将其设置为false Then simply check it's value at runtime, and act accordingly. 然后只需在运行时检查它的值,然后采取相应措施即可。

Also, there is a getInstallerPackageName() method in PackageManager which can be used for this purpose. 另外, PackageManager有一个getInstallerPackageName()方法可用于此目的。 However, this value is not reliable and may be tampered with. 但是,此值不可靠,可能会被篡改。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 即使已将android应用程序从设备中删除,如何检查是否已安装 - How to check if an android application was installed even if it is removed from the device Titanium:检查设备上是否安装了应用程序(android) - Titanium: Check if application installed on the device (android) 如何检查 Android 设备上安装的 Fonts - How to check Installed Fonts on Android Device 如何查看 android 设备中是否安装了 Whatsapp? - How to check Whatsapp is installed in device in android? 检查是否安装了应用程序 - Android - Check if application is installed - Android 如何以编程方式检查 Android 中是否安装了应用程序? - How to check programmatically if an application is installed or not in Android? 当使用android-facebook api时,如何忽略设备上安装的Facebook android应用程序? - How to ignore Facebook android application installed on the device, when using android-facebook api? Android:如何知道是否已经使用 adb 在 android 设备中安装了任何应用程序? - Android: How to Know if any application is already installed in android device using adb? Android和Javascript:如何在javascript中了解是否已在Android设备中安装了应用程序? - Android and Javascript: How to know in javascript that an application is installed in the Android device or not? 如何使用wifi将数据发送到安装在其他Android设备上的同一个应用程序 - How to send data to the same application installed on other android device using wifi
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM