【问题标题】:'isGooglePlayServicesAvailable'(this) is deprecated'isGooglePlayServicesAvailable'(this) 已弃用
【发布时间】:2017-05-22 05:13:45
【问题描述】:

我正在学习使用谷歌位置服务的教程。所以,我正在尝试使用 Google API 服务获取位置。但我得到了isGooglePlayServicesAvailable(this) is deprecated 错误。任何人都可以帮忙。谢谢

以下是我检查设备上是否存在 Play 服务的代码:

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 {
            Toast.makeText(getApplicationContext(),
                    "This device is not supported", Toast.LENGTH_LONG)
                    .show();
            finish();
        }
        return false;
    }
    return true;
}

【问题讨论】:

标签: java android android-studio


【解决方案1】:

改用isGooglePlayServicesAvailable

GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(context)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-08-19
    • 2014-02-12
    • 1970-01-01
    • 2021-01-01
    • 1970-01-01
    • 2016-03-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多