- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在关注 this guide检查 GoogleApiAvailability,它需要我调用 getErrorDialog(int responseCode)
however, the result code is SERVICE_MISSING, SERVICE_VERSION_UPDATE_REQUIRED, or SERVICE_DISABLED, then the user needs to install an update. In this case, call the getErrorDialog() method and pass it the result error code.
该指南用于 getErrorDialog(int responseCode)但是this page (getErrorDialog 上的超链接)表示该方法已弃用
This method was deprecated. Use getErrorDialog(Activity, int, int) instead.
根据文档,第一个 int
是请求代码,第二个 int
是响应代码。我从 isGoogleApiAvailable(context)
获得了响应代码,但我不知道请求代码是什么以及如何获得它。
这是我的代码:
// Ensure Google Play services framework is installed
int gAAResult = GoogleApiAvailability
.getInstance()
.isGooglePlayServicesAvailable(this);
if(gAAResult == ConnectionResult.SUCCESS){
Log.d(TAG, "Play services available");
} else {
GoogleApiAvailability
.getInstance()
.getErrorDialog(this, ? ,gAAResult);
}
将问号替换为实际请求代码的地方作为临时解决方案,我已将 0 传递给它。我没有没有播放服务的设备。在模拟器上,该应用程序显示一个对话框(没有我的代码)来更新播放服务。但是 FCM 文档建议对这个检查进行编码
最佳答案
第一个 int 是 connectionResult
,由 isGooglePlayServicesAvailable(Context context)
方法返回。第二个是用于错误对话框的 requestCode
。
显示错误对话框后,您将在 Activity 的方法 onActivityResult(int requestCode, int result, Intent data)
中获得回调,其中包含结果和传递的请求代码。由于您可能会从一个执行后结果开始多个 Activity ,getErrorDialog(...)
方法会要求您传递一个请求代码作为操作的唯一标识符,以帮助您处理结果。
您实际上需要实现这一点,因为通用的 Play 服务错误对话框可能会帮助用户更新他/她手机上的 Play 服务,因此您会收到问题已实际解决的通知。如果您不那么幸运,情况也是如此。
关于android - 如何获取新的 GoogleApiAvailability.getErrorDialog() 的请求代码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47891937/
我从 Google Play 服务 11.0.4 切换到 18.1.1 并在以下代码中遇到编译器错误: public boolean isGooglePlayServicesAvailable() {
我正在尝试在我的 Android 应用中使用 Google Play 服务。正如谷歌文档所说,我们需要在使用之前检查谷歌 API 是否可用。我已经搜索了一些方法来检查它。这是我得到的: private
我正在关注 this guide检查 GoogleApiAvailability,它需要我调用 getErrorDialog(int responseCode) however, the result
背景 我有一个应用了以下主题的 Activity: @color/light_blue @color/dark_blue @color/mid_blue @color
我遇到一个问题,当我直接在手机上运行应用程序时,应用程序启动成功,但当我在模拟器上尝试它时,它在启动之前崩溃并出现错误: 01-15 14:30:35.037 3735-3735/com.examp
声明依赖为 compile 'com.google.firebase:firebase-messaging:9.4.0' 我在 Activity 的导入行中收到“无法解析符号 GoogleApiAva
将依赖声明为 compile 'com.google.firebase:firebase-messaging:9.4.0' 我在 Activity 的导入行中收到“无法解析符号 GoogleApiAv
我像这样包含了 play-services-analytics 库: dependencies { compile 'com.android.support:appcompat-v7:23.1
我正在努力集成 arcore 和 mediapipe 应用程序。但是当我尝试在 mediapipe 源代码中集成 arcore 时,我遇到了 session 对象的问题,如下所示。 尝试创建 ARCo
我是一名优秀的程序员,十分优秀!