isGooglePlayServicesAvailable始终返回false
问题描述:
我想使用谷歌播放服务的位置,但每次我用下面的代码:isGooglePlayServicesAvailable始终返回false
resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
我会回来虚假仅作为一个结果。当然,当我想初始化一个新的位置客户端(我知道它已经过时)
mLocationClient = new LocationClient(this, this, this);
我只得到虚假回来。 我的错误在哪里?是否需要在手机上更新Google Play服务?我已经检查过系统更新,其中有最新的一个。这是一个银河S5迷你,如果这可能有所帮助。
答
有几种可能性,你得到的是错误
- 服务已经过时
- 服务被禁用/删除
- 另一个三星相关的bug
我已经使用这个功能检查服务是否足够新,否则我会得到一个对话框,并重定向到谷歌播放更新它们
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 {
finish();
}
return false;
}
return true;
}
它会显示错误。
答
成功时isGooglePlayServicesAvailable返回0,你可以在这里看到的方法: https://developers.google.com/android/reference/com/google/android/gms/common/ConnectionResult#SERVICE_SUCCESS
所以,0 =假...