Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android 8 or higher: Check for Google Play Services

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()));
    }
like image 766
Mark Molina Avatar asked Dec 07 '12 16:12

Mark Molina


People also ask

How do I fix Google Play Services error?

Clear Cache and Data This fix will also be useful when troubleshooting other apps. Open Settings on your Android phone. Tap on “Apps” and “Google Play Services” under the “All apps” section. Select “Storage,” then press the “Clear cache” button followed by the “Clear data” or “Clear storage” button.

Why can't I update Google Play Services?

If still you cannot update Google Play Services, clearing cache can solve your problem. We also stated about this in the beginning as the reason. If you don't know, cache holds the app's data temporarily so that it can remember the information when you next open the app. Many times, old cache files get corrupted.

Why Google Play Services is not supported by my device?

When Google Play service finds any app to be outdated it might reflect this error on your Android device. So another potential solution you can try is to update all other apps on your device to get rid of the Google Play services unsupportable on your device error.


2 Answers

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
}
like image 69
Raghav Sood Avatar answered Oct 09 '22 09:10

Raghav Sood


Please read the documentation: 0 is SUCCESS

public static final int SUCCESS
The connection was successful.
Constant Value: 0 (0x00000000)

Documentation

like image 38
Rawkode Avatar answered Oct 09 '22 08:10

Rawkode