Android的8或更高版本:检查谷歌播放服务 [英] Android 8 or higher: Check for Google Play Services
问题描述
此方法回头率0据开发文档此方法应该返回类似SUCCES如果该设备得到了谷歌最新版本的播放。是否有人知道如何使用它?
@覆盖
公共无效onResume(){
super.onResume();
GooglePlayServicesUtil.isGooglePlayServicesAvailable(getApplicationContext());
的System.out.println(henkie:+ GooglePlayServicesUtil.isGooglePlayServicesAvailable(getApplicationContext()));
}
它返回成功
。该<一href="http://developer.android.com/reference/com/google/android/gms/common/GooglePlayServicesUtil.html#isGooglePlayServicesAvailable%28android.content.Context%29"相对=nofollow>文档明确指出,该方法有一个int返回类型,并返回一个
状态code指示是否出现了错误。可以是一种 按照ConnectionResult:成功,SERVICE_MISSING, SERVICE_VERSION_UPDATE_REQUIRED,SERVICE_DISABLED,SERVICE_INVALID。
要检查什么返回,使用这样的:
INT状态= GooglePlayServicesUtil.isGooglePlayServicesAvailable(getApplicationContext());
如果(状态== ConnectionResult.SUCCESS){
//成功!做你要做的
}
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?
@Override
public void onResume() {
super.onResume();
GooglePlayServicesUtil.isGooglePlayServicesAvailable(getApplicationContext());
System.out.println("henkie: " + GooglePlayServicesUtil.isGooglePlayServicesAvailable(getApplicationContext()));
}
It is returning SUCCESS
. The documentation clearly states that the method had an int return type, and returns 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.
To check against what was returned, use something like:
int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getApplicationContext());
if(status == ConnectionResult.SUCCESS) {
//Success! Do what you want
}
这篇关于Android的8或更高版本:检查谷歌播放服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!