android - getErrorDialog 已贬值。更新后的功能是什么,我该如何使用它?

标签 android

我目前正在尝试将 Drive API 授权的使用整合到我的应用中。

Google Developers Guide 指出我必须在我的连接失败方法中使用 getErrorDialog。

但是,当我放入 getErrorDialog 时,它指出该方法已过时,我需要使用“更新”版本。

但是,它没有说明我应该使用什么。

有谁知道这个函数的更新版本吗?

最佳答案

However, when I put the getErrorDialog in, it stated that the method was depreciated, and that I needed to use an 'updated' version.

GooglePlayServicesUtil.getErrorDialog 已被弃用,取而代之的是 GoogleApiAvailability.getErrorDialog ,它不是 GooglePlayServicesUtil 的静态方法。您可以通过这种方式获取 GoogleApiAvailability 的实例

GoogleApiAvailability apiAvailability = GoogleApiAvailability.getInstance();

并对返回的实例调用getErrorDialog

apiAvailability.getErrorDialog(this, resultCode, PLAY_SERVICES_RESOLUTION_REQUEST).show();

这是 Context 的对象,resultCodeisGooglePlayServicesAvailable(Context) 的返回值。您可以阅读更多相关信息 here

关于android - getErrorDialog 已贬值。更新后的功能是什么,我该如何使用它?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38375849/

相关文章:

android - 父 Activity 在退出过渡时变得不可见

java - XML 解析器返回意外的标记错误和空指针异常

Android:如何将 "Custom View"动态添加到线性布局中

java - Android 工作室设备

android - 显示 Internet 设置的对话框窗口

android - 在 Jelly Bean 上使用 overridePendingTransition 时屏幕随机闪烁

安卓NDK : override dynamic linking for native libraries?

java - 如何在Android Studio中添加多个声音按钮?

android - 如何将 mapview 渲染为一个圆圈?

android - Android 4.0 及以上版本的视频观看问题