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
}

相关文章

HashMap是Java中最常用的集合类框架,也是Java语言中非常典型...
在EffectiveJava中的第 36条中建议 用 EnumSet 替代位字段,...
介绍 注解是JDK1.5版本开始引入的一个特性,用于对代码进行说...
介绍 LinkedList同时实现了List接口和Deque接口,也就是说它...
介绍 TreeSet和TreeMap在Java里有着相同的实现,前者仅仅是对...
HashMap为什么线程不安全 put的不安全 由于多线程对HashMap进...