Java – Android 8 or later: check Google play service

The method keeps returning 0 According to the developer documentation, if the device obtains the latest version of Google play, this method should return a success like method Does anyone know how to use this?

@Override
    public void onResume() {
        super.onResume();

        GooglePlayServicesUtil.isGooglePlayServicesAvailable(getApplicationContext());
        System.out.println("henkie: " + GooglePlayServicesUtil.isGooglePlayServicesAvailable(getApplicationContext()));
    }

Solution

It is returning success Documentation clearly indicates that the method has an int return type and returns an int

To check what is returned, use the following:

int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getApplicationContext());
if(status == ConnectionResult.SUCCESS) {
    //Success! Do what you want
}
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>