Reputation: 5077
this method keep returning 0. According to the developer docs this method should return something like SUCCES if the device got the newest version of google play. Does anybody know how to use this?
@Override
public void onResume() {
super.onResume();
GooglePlayServicesUtil.isGooglePlayServicesAvailable(getApplicationContext());
System.out.println("henkie: " + GooglePlayServicesUtil.isGooglePlayServicesAvailable(getApplicationContext()));
}
Upvotes: 9
Views: 13881
Reputation: 82533
It is returning SUCCESS
. The documentation clearly states that the method had an int return type, and returns a
status code indicating whether there was an error. Can be one of following in ConnectionResult: SUCCESS, SERVICE_MISSING, SERVICE_VERSION_UPDATE_REQUIRED, SERVICE_DISABLED, SERVICE_INVALID.
To check against what was returned, use something like:
int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getApplicationContext());
if(status == ConnectionResult.SUCCESS) {
//Success! Do what you want
}
Upvotes: 40
Reputation: 2934
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();
}
Upvotes: 3
Reputation: 15834
Simply
int statusCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getApplicationContext());
if (statusCode == ConnectionResult.SUCCESS) {
//OK
}
Upvotes: 4
Reputation: 22562
Please read the documentation: 0
is SUCCESS
public static final int SUCCESS
The connection was successful.
Constant Value: 0 (0x00000000)
Upvotes: 7