加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Java > 正文

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

发布时间:2020-12-14 05:31:30 所属栏目:Java 来源:网络整理
导读:该方法保持返回0.根据开发者文档,如果设备获得最新版本的Google Play,此方法应该返回类似SUCCES的方法.有人知道如何使用这个吗? @Override public void onResume() { super.onResume(); GooglePlayServicesUtil.isGooglePlayServicesAvailable(getApplicati
该方法保持返回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
}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读