Android 8或更高版本:查看谷歌播放服务

时间:2022-06-08 06:59:44

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?

这个方法一直返回0。根据开发人员的文档,如果设备获得了最新版本的谷歌play,那么这个方法应该会返回一些类似于SUCCES的东西。有人知道怎么用这个吗?

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

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

4 个解决方案

#1


40  

It is returning SUCCESS. The documentation clearly states that the method had an int return type, and returns a

它是成功返回。文档清楚地说明该方法具有int返回类型,并返回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.

状态码,指示是否有错误。在ConnectionResult中可以遵循以下内容:成功、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
}

#2


7  

Please read the documentation: 0 is SUCCESS

请阅读文档:0表示成功

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

Documentation

文档

#3


4  

Simply

简单的

int statusCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getApplicationContext());
if (statusCode == ConnectionResult.SUCCESS) {
    //OK
}

#4


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();
        }

#1


40  

It is returning SUCCESS. The documentation clearly states that the method had an int return type, and returns a

它是成功返回。文档清楚地说明该方法具有int返回类型,并返回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.

状态码,指示是否有错误。在ConnectionResult中可以遵循以下内容:成功、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
}

#2


7  

Please read the documentation: 0 is SUCCESS

请阅读文档:0表示成功

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

Documentation

文档

#3


4  

Simply

简单的

int statusCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getApplicationContext());
if (statusCode == ConnectionResult.SUCCESS) {
    //OK
}

#4


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();
        }