java 'isGooglePlayServicesAvailable'(this) 已弃用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/41522670/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
'isGooglePlayServicesAvailable'(this) is deprecated
提问by Muhamad Hishamudin
I'm following a tutuorial to use google location services. So, I'm trying to get location using Google API service. But I got isGooglePlayServicesAvailable
(this) is deprecated error. Can anyone help. Thanks
我正在按照教程使用谷歌定位服务。所以,我正在尝试使用 Google API 服务获取位置。但是我得到了isGooglePlayServicesAvailable
(this) is deprecated 错误。任何人都可以帮忙。谢谢
Below is my code for checking if Play services exist on device:
以下是我用于检查设备上是否存在 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;
}
回答by Phan Van Linh
Use isGooglePlayServicesAvailableinstead
使用isGooglePlayServicesAvailable代替
GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(context)