[英]When does isGooglePlayServicesAvailable return SERVICE_VERSION_UPDATE_REQUIRED?
According to the documentation GooglePlayServicesUtil.isGooglePlayServicesAvailable returns SERVICE_VERSION_UPDATE_REQUIRED when "The installed version of Google Play services is out of date". 根据文档,当“已安装的Google Play服务版本已过期”时, GooglePlayServicesUtil.isGooglePlayServicesAvailable会返回SERVICE_VERSION_UPDATE_REQUIRED 。
Does this mean that there is a new version of google play services in the play store? 这是否意味着Play商店中有新版本的google play服务?
Does this mean that the app needs a newer version than the one that is currently installed in the device? 这是否意味着应用程序需要比当前安装在设备中的版本更新的版本?
How is this check done? 怎么做这个检查?
this means that the version of google play service you included in your app is higher than the one currently installed on the users device. 这意味着您在应用中添加的Google Play服务版本高于用户设备上当前安装的版本。 the user needs to update their google play services in-order for your app to work correctly. 用户需要更新其Google Play服务才能使您的应用正常运行。
if the result comes back with that error you can simply call this method to alert the user they need to update and it will take them there. 如果结果返回错误,您可以简单地调用此方法来提醒用户他们需要更新,并将它们带到那里。
GooglePlayServicesUtil.getErrorDialog(result, this, GOOGLE_PLAY_SERVICE_UPDATE_CODE).show();
result
is the result of the isGooglePlayServicesAvailable
method result
是isGooglePlayServicesAvailable
方法的结果
Here are the docs for GooglePlayServicesUtil
: http://developer.android.com/reference/com/google/android/gms/common/GooglePlayServicesUtil.html . 以下是GooglePlayServicesUtil
的文档: http : //developer.android.com/reference/com/google/android/gms/common/GooglePlayServicesUtil.html 。
Here is where they talking about "ensuring" the user has it installed: https://developer.android.com/google/play-services/setup.html#ensure 以下是他们谈论“确保”用户安装它的地方: https : //developer.android.com/google/play-services/setup.html#ensure
This is taken from the Official Iosched 2014 source code here: https://github.com/google/iosched/blob/0a90bf8e6b90e9226f8c15b34eb7b1e4bf6d632e/android/src/main/java/com/google/samples/apps/iosched/util/PlayServicesUtils.java 这取自官方Iosched 2014源代码: https : //github.com/google/iosched/blob/0a90bf8e6b90e9226f8c15b34eb7b1e4bf6d632e/android/src/main/java/com/google/samples/apps/iosched/util/PlayServicesUtils。 java的
public class PlayServicesUtils {
public static boolean checkGooglePlaySevices(final Activity activity) {
final int googlePlayServicesCheck = GooglePlayServicesUtil.isGooglePlayServicesAvailable(activity);
switch (googlePlayServicesCheck) {
case ConnectionResult.SUCCESS:
return true;
case ConnectionResult.SERVICE_DISABLED:
case ConnectionResult.SERVICE_INVALID:
case ConnectionResult.SERVICE_MISSING:
case ConnectionResult.SERVICE_VERSION_UPDATE_REQUIRED:
Dialog dialog = GooglePlayServicesUtil.getErrorDialog(googlePlayServicesCheck, activity, 0);
dialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialogInterface) {
activity.finish();
}
});
dialog.show();
}
return false;
}
}
Here is how to use it in an Activity
: https://github.com/google/iosched/blob/cf1f30b4c752f275518384a9b71404ee501fc473/android/src/main/java/com/google/samples/apps/iosched/ui/BaseActivity.java 以下是在Activity
使用它的方法: https : //github.com/google/iosched/blob/cf1f30b4c752f275518384a9b71404ee501fc473/android/src/main/java/com/google/samples/apps/iosched/ui/BaseActivity.java
@Override
protected void onResume() {
super.onResume();
// Verifies the proper version of Google Play Services exists on the device.
PlayServicesUtils.checkGooglePlaySevices(this);
}
Does this mean that there is a new version of google play services in the play store? 这是否意味着Play商店中有新版本的google play服务?
From the site latest update was on December 2014 从该网站最新更新于2014年12月
Does this mean that the app needs a newer version than the one that is currently installed in the device? 这是否意味着应用程序需要比当前安装在设备中的版本更新的版本?
You can check if the device has the higher version of Google Play Service
than the one on your app like so: 您可以检查设备是否具有比您应用中的Google Play Service
更高版本的Google Play Service
,如下所示:
int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable( getApplicationContext() );
if(status == ConnectionResult.SUCCESS) {
//OK
}else if(status == ConnectionResult.SERVICE_VERSION_UPDATE_REQUIRED){
Toast.makeText(context,"please udpate your google play service",Toast.LENGTH_SHORT).show
}
Documentation was updated, now it is clear: 文档已更新,现在很清楚:
Verifies that Google Play services is installed and enabled on this device, and that the version installed on this device is no older than the one required by this client . 验证是否已在此设备上安装并启用Google Play服务,并且此设备上安装的版本不早于此客户端所需的版本 。
Note that all of the current answers reference GooglePlayServicesUtil which is now deprecated. 请注意,所有当前答案都引用了现已弃用的GooglePlayServicesUtil。 See GooglePlayServicesUtil vs GoogleApiAvailability for details on how to perform the Google Play Services version compatibility check. 有关如何执行Google Play服务版本兼容性检查的详细信息,请参阅GooglePlayServicesUtil与GoogleApiAvailability 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.