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?(不是市场)


- URL编码Swift iOS 2022-01-01
- 网上有没有好的 UIScrollView 教程? 2022-01-01
- GPS状态的广播接收器? 2022-01-01
- 类似于 Mail.app 的 iPad 模态视图控制器? 2022-01-01
- 使用自动布局向 UIScrollView 添加动态大小的视图 2022-01-01
- 如何在 iPhone 模拟器中重置 NSUserDefaults 数据? 2022-01-01
- UITextView 内容插图 2022-01-01
- SetOnItemSelectedListener上的微调程序错误 2022-01-01
- Xcode 7.3 中带有 UILabel 的 UIStackView 2022-01-01
- 在 Iphone SDK 的导航栏上添加多个按钮 2022-01-01