微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

java – Android 8或更高版本:检查Google Play服务

方法保持返回0.根据开发者文档,如果设备获得最新版本的Google Play,此方法应该返回类似SUCCES的方法.有人知道如何使用这个吗?
@Override
    public void onResume() {
        super.onResume();

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

解决方法

它正在返回成功. documentation清楚地表示该方法一个int返回类型,并返回一个

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.

要检查所返回的内容,请使用以下内容

int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getApplicationContext());
if(status == ConnectionResult.SUCCESS) {
    //Success! Do what you want
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐