java - 如何处理 GooglePlayServicesRepairableException 和 GooglePlayServicesNotAvailableException

标签 java android google-play-services

我阅读了官方文档,这让我很困惑。有什么区别 GooglePlayServicesRepairableExceptionGooglePlayServicesNotAvailableException。什么时候扔?如何处理这些错误?如何向用户显示一个对话框,他可以在其中启用/更新/安装服务。等等

private void startLocationPicker() {
        try {
            new PlacePicker.IntentBuilder().build(this);
        } catch (GooglePlayServicesRepairableException e) {

        } catch (GooglePlayServicesNotAvailableException e) {

        }
    }

最佳答案

GooglePlayServicesRepairableException docs 中所述:

GooglePlayServicesRepairableExceptions are special instances of UserRecoverableExceptions which are thrown when Google Play Services is not installed, up-to-date, or enabled. In these cases, client code can use getConnectionStatusCode() in conjunction with getErrorDialog(android.app.Activity, int, int) to provide users with a localized Dialog that will allow users to install, update, or otherwise enable Google Play services.

GooglePlayServicesNotAvailableException还有一个错误代码可以与 getErrorDialog() 一起使用,尽管我鼓励您查看 GoogleApiAvailability 中可用的所有方法。 .

关于java - 如何处理 GooglePlayServicesRepairableException 和 GooglePlayServicesNotAvailableException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37448163/

相关文章:

android - GoogleMap 在 Android API 23 上将为空

android - 使用已弃用的方法解决 GoogleAccountCredential.RequestHandler

android - 在哪里向 Google 报告 API 错误? (谷歌附近消息 API)

java - 当用 Java 正则表达式替换反斜杠时,为什么 Pattern 类不能识别单个反斜杠?

java - Spring Data REST 存储库中的枚举翻译

java - 如何使用 JAVA API 配置我的索引以在 ElasticSearch 中使用 BM25?

java - 发送多个请求以获得最终响应还是保留第一个请求?

android - 在 Google Cardboard Android SDK 中选择 GLES 版本

android - 当我们在 Firebase 中调用 push() 生成 key 时,位置是否重要?

android - ffmpeg编译时出错