简体   繁体   English

如何检查Android设备是否已安装Google Play?

[英]How to check if an android device has Google Play installed?

I am trying to check if the device has Google Play installed or not in my app, but seems there is no way to do that. 我正在尝试检查设备是否在我的应用程序中安装了Google Play,但似乎无法执行此操作。 I followed the post HERE but still doesn't work, always return true even i was testing with an emulator, it has com.android.vending installed. 我按照这里的帖子,但仍然无法正常工作,即使我正在使用模拟器进行测试,也始终返回true,它安装了com.android.vending。 So am i checking the wrong package name? 我是否检查了错误的包裹名称? Any ideas for that? 有什么想法吗?

Thanks in advance! 提前致谢!

Follow Dcoumentation to check if the device has Google Play Service available. 按照Dcoumentation检查设备是否有可用的Google Play服务。

In Short, simply: 简而言之,简单地:

// Getting status
int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getBaseContext());

// Showing status
if(status==ConnectionResult.SUCCESS)
//Google Play Services are available
else{
//Google Play Services are not available
}

Hope this will help you :) 希望这个能对您有所帮助 :)

Finally, found a way to check Google Play installed, here is the code: 最后,找到一种检查安装的Google Play的方法,下面是代码:

public static boolean isPackageInstalled(Context context) {
    PackageManager pm = context.getPackageManager();
    boolean app_installed = false;
    try {
       PackageInfo info = pm.getPackageInfo("com.android.vending", PackageManager.GET_ACTIVITIES);
       String label = (String) info.applicationInfo.loadLabel(pm);
       app_installed = (!TextUtils.isEmpty(label) && label.startsWith("Google Play"));
    } catch(PackageManager.NameNotFoundException e) {
       app_installed = false;
    }
    return app_installed;
}

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

相关问题 以编程方式检查 android 设备是否有 Google Play? - Programmatically check if android device has Google Play? 如何检查Android设备是否具有在10.2或更高版本上运行的Google Play服务 - How to check the whether the android device has google play services running on 10.2 or greater 如何检查用户设备上安装了哪个版本的 Google Play GAMES - How to check what version of Google Play GAMES is installed on user's device 如何检查用户是否在 Android、Google Play 中拥有有效订阅? - How to check if the user has an active subscription in Android, Google Play? 如何检查当前的Android设备是否具有Google的位置服务? - How to check if the current Android device has Google's location service? 无法确定 Android 设备上是否安装了 Google Play 商店 - Cannot determine whether Google play store is installed or not on Android device 如何在我的 android 设备上禁用已安装的 Google Play 服务版本? - How do i disable installed version of Google Play services on my android device? 如何查看 android 设备中是否安装了 Whatsapp? - How to check Whatsapp is installed in device in android? 如何检查 Android 设备上安装的 Fonts - How to check Installed Fonts on Android Device Android:Google Play是否检查已安装的APK的versionCode? - Android: Does Google Play check versionCodes of installed apks?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM