我正在学习使用Google定位服务的教程。因此,我正在尝试使用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;
}
最佳答案
改用isGooglePlayServicesAvailable
GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(context)