How to detect if Google Play is installed? (Not Market)(如何检测是否安装了 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,除了 versionCode 和 versionName 没有任何帮助.
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 应用的第一个 versionCode 或 versionName 是什么吗?
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?(不是市场)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何检测是否安装了 Google Play?(不是市场)
基础教程推荐
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- iOS4 创建后台定时器 2022-01-01
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
