'isGooglePlayServicesAvailable'(this) 已弃用
2022-09-01 08:03:38
我正在跟随一个tutuorial使用谷歌位置服务。因此,我正在尝试使用Google API服务获取位置。但是我得到了(这个)是弃用的错误。任何人都可以帮忙。谢谢isGooglePlayServicesAvailable
以下是我用于检查设备上是否存在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;
}