android - 带有 GooglePlayServicesUtil.get Error Dialog() 的 Google Maps Android 应用程序

标签 android google-maps google-play-services

所以在这里的文档中

http://developer.android.com/google/play-services/setup.html

它说使用 isGooglePlayServicesAvailable() 检查播放服务的状态,如果不正常则显示错误对话框。

这对我来说似乎工作正常,显示它未安装的对话框带有打开 Play 商店的按钮似乎一切正常。我的问题专门针对 onActivityResult() 中的返回结果。

我们必须将 requestCode 传递给 getErrorDialog() 并且我在 onActivityResult 中得到它就好了,但我更关心resultCode 返回。到目前为止,在我所有的测试中,我得到了 0 (RESULT_CANCELLED)。请问有什么方法可以知道播放服务是否安装成功?

现在我只是假设 RESULT_CANCELLED 意味着他们至少到达了 play 商店并开始下载,并显示另一个对话框,上面写着“请在播放后重新启动此应用程序”服务完成安装”,然后是 finish()

这是最好的处理方式吗?还是我遗漏了返回 RESULT_OK 的情况,我可以继续使用我的应用程序而无需重新启动它?

最佳答案

我必须说,今天我试过了,但我从来没有调用过 onActivityResult()。

当对话框被取消时,我的 OnCancelListener(getErrorDialog() 参数)被调用,当从 PlayStore 返回时,无论是否安装 Google Play 服务,我的应用程序都会被销毁。

更重要的是,在安装 Google Play Services 时,onDestroy() 会在安装开始时被调用。

我认为这可能是一种更新的行为,我认为这是必然的,因为您可以在后台安装结束之前从 Play 商店返回。

尽管如此,我发现了几个带有示例代码的链接,可以确认在调用 onActivityResult() 时出现 RESULT_OK,这意味着您可以继续:

http://developer.android.com/training/location/activity-recognition.html

http://developer.android.com/training/location/retrieve-current.html

希望对你有帮助

关于android - 带有 GooglePlayServicesUtil.get Error Dialog() 的 Google Maps Android 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15258550/

相关文章:

android - 如何监听android MediaPlayer位置改变事件

java - 如何在android中的googlemap中显示所有标记标题

android - 在没有 google_play_services.json 或 gradle 的情况下设置 google_app_id

android - GCM 示例项目错​​误消息 "Could not find google-play-services_lib.apk"

android - 在按钮背景上设置 GIF

android - 为什么使用 fragment ,以及何时使用 fragment 而不是 Activity ?

java - android - 包括布局或 fragment

javascript - 在谷歌地图上使用 MarkerWithLabel 隐藏标记

javascript - Google Maps API v3 标记是否带有图像和该图像顶部的文本?

android - Firebase App Distribution - Google Play 窗口上没有 "install"按钮