相关疑难解决方法(0)

GooglePlayServicesUtil与GoogleApiAvailability

我想在我的Android应用中使用Google Play服务.正如Google文档所述,我们需要在使用之前检查Google API是否可用.我已经搜索了一些方法来检查它.这是我得到的:

private boolean checkPlayServices() {
int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
if (resultCode != ConnectionResult.SUCCESS) {
    if (GooglePlayServicesUtil.isUserRecoverableError(resultCode)) {
        GooglePlayServicesUtil.getErrorDialog(resultCode, this,
                PLAY_SERVICES_RESOLUTION_REQUEST).show();
    } else {
        Log.i(TAG, "This device is not supported.");
        finish();
    }
    return false;
}
return true;
}
Run Code Online (Sandbox Code Playgroud)

但是,当我访问Google Api GooglePlayServicesUtil页面时, 请访问https://developers.google.com/android/reference/com/google/android/gms/common/GooglePlayServicesUtil

我发现所有功能都已弃用.例如,该方法

GooglePlayServicesUtil.isGooglePlayServicesAvailable(不建议使用)

谷歌建议使用:

GoogleApiAvailability.isGooglePlayServicesAvailable.

但是,当我尝试使用GoogleApiAvailability.isGooglePlayServicesAvailable时,收到错误消息:

在此输入图像描述

android

100
推荐指数
4
解决办法
5万
查看次数

标签 统计

android ×1