此方法继续返回0.根据开发人员文档,如果设备获得最新版本的google play,此方法应返回类似SUCCES的内容。有人知道如何使用它吗?
@Override
public void onResume() {
super.onResume();
GooglePlayServicesUtil.isGooglePlayServicesAvailable(getApplicationContext());
System.out.println("henkie: " + GooglePlayServicesUtil.isGooglePlayServicesAvailable(getApplicationContext()));
}
答案 0 :(得分:40)
它正在返回SUCCESS
。 documentation清楚地表明该方法具有int返回类型,并返回
状态代码,指示是否有错误。可以是其中之一 以下是ConnectionResult:SUCCESS,SERVICE_MISSING, SERVICE_VERSION_UPDATE_REQUIRED,SERVICE_DISABLED,SERVICE_INVALID。
要检查返回的内容,请使用以下内容:
int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getApplicationContext());
if(status == ConnectionResult.SUCCESS) {
//Success! Do what you want
}
答案 1 :(得分:7)
请阅读文档:0
为SUCCESS
public static final int SUCCESS
The connection was successful.
Constant Value: 0 (0x00000000)
答案 2 :(得分:4)
简单地
int statusCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getApplicationContext());
if (statusCode == ConnectionResult.SUCCESS) {
//OK
}
答案 3 :(得分:3)
int state = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
if (state == ConnectionResult.SUCCESS) {
Toast.makeText(this, "SUCCESS", Toast.LENGTH_LONG).show();
//goAhead();
} else {
Dialog dialog = GooglePlayServicesUtil.getErrorDialog(state, this, -1);
dialog.show();
}