我正在学习使用谷歌位置服务的教程。所以,我正在尝试使用 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;
}
最佳答案
使用 isGooglePlayServicesAvailable而是
GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(context)
关于java - 'isGooglePlayServicesAvailable'(this) 已弃用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41522670/