如何检测是否安装了 Google Play?(不是市场) [英] How to detect if Google Play is installed? (Not Market)

查看:24
本文介绍了如何检测是否安装了 Google Play?(不是市场)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

无论安装的应用是Google Play还是Market,包名都是一样的com.android.vending.

Whether the app installed is called Google Play or Market, the package name is the same com.android.vending.

我需要能够检测应用程序是 Google Play 还是 Market,我已经检查了 PackageInfo,除了 versionCodeversionName 没有任何帮助.

I need to be able to detect whether the app is Google Play or Market, I've checked in PackageInfo and nothing except versionCode and versionName can be of help.

有人知道 Google Play 应用的第一个 versionCodeversionName 是什么吗?

Does anyone know what the first versionCode was or versionName was for Google Play app?

如果有人知道任何其他检测方法,请告诉我.

If anyone knows any other way of detecting this let me know.

推荐答案

我想出了如何检查应用程序标签.我正在使用调试器查看 packageInfo 中返回的所有内容,这就是我最初没有看到它的原因.

I figured out how to check the application label. I was using the debugger to see what all was being returned in packageInfo that's why I didn't see it initially.

public static boolean isGooglePlayInstalled(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 = (label != null && !label.equals("Market"));
    }
    catch (PackageManager.NameNotFoundException e)
    {
           app_installed = false;
    }
    return app_installed;
}

这篇关于如何检测是否安装了 Google Play?(不是市场)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆