什么时候 isGooglePlayServicesAvailable return SERVICE_VERSION_UPDATE_REQUIRED?
When does isGooglePlayServicesAvailable return SERVICE_VERSION_UPDATE_REQUIRED?
根据文档 GooglePlayServicesUtil.isGooglePlayServicesAvailable returns SERVICE_VERSION_UPDATE_REQUIRED 当 "The installed version of Google Play services is out of date"。
这是否意味着 Play 商店中有 google Play 服务的新版本?
这是否意味着该应用程序需要比设备中当前安装的版本更新的版本?
这项检查是如何完成的?
这意味着您在应用中包含的 google 播放服务的版本高于用户设备上当前安装的版本。用户需要更新他们的 google 播放服务,以便您的应用正常运行。
如果结果返回该错误,您可以简单地调用此方法来提醒用户他们需要更新,它将把他们带到那里。
GooglePlayServicesUtil.getErrorDialog(result, this, GOOGLE_PLAY_SERVICE_UPDATE_CODE).show();
result
是isGooglePlayServicesAvailable
方法的结果
Does this mean that there is a new version of google play services in the play store?
来自 site 的最新更新是 2014 年 12 月
Does this mean that the app needs a newer version than the one that is currently installed in the device?
您可以检查设备的 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
}
这是 GooglePlayServicesUtil
的文档: http://developer.android.com/reference/com/google/android/gms/common/GooglePlayServicesUtil.html.
这是他们谈论 "ensuring" 用户安装它的地方: https://developer.android.com/google/play-services/setup.html#ensure
这里取自官方 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;
}
}
中使用它
@Override
protected void onResume() {
super.onResume();
// Verifies the proper version of Google Play Services exists on the device.
PlayServicesUtils.checkGooglePlaySevices(this);
}
请注意,所有当前答案都引用了现在已弃用的 GooglePlayServicesUtil。有关如何执行 Google Play 服务版本兼容性检查的详细信息,请参阅 GooglePlayServicesUtil vs GoogleApiAvailability。
文档已更新,现在很清楚:
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.
我通过更新最新版本的 Youtube 库解决了这个问题:https://developers.google.com/youtube/android/player/downloads
在gradle中:
implementation files('libs/YouTubeAndroidPlayerApi.jar')
根据文档 GooglePlayServicesUtil.isGooglePlayServicesAvailable returns SERVICE_VERSION_UPDATE_REQUIRED 当 "The installed version of Google Play services is out of date"。
这是否意味着 Play 商店中有 google Play 服务的新版本?
这是否意味着该应用程序需要比设备中当前安装的版本更新的版本?
这项检查是如何完成的?
这意味着您在应用中包含的 google 播放服务的版本高于用户设备上当前安装的版本。用户需要更新他们的 google 播放服务,以便您的应用正常运行。
如果结果返回该错误,您可以简单地调用此方法来提醒用户他们需要更新,它将把他们带到那里。
GooglePlayServicesUtil.getErrorDialog(result, this, GOOGLE_PLAY_SERVICE_UPDATE_CODE).show();
result
是isGooglePlayServicesAvailable
方法的结果
Does this mean that there is a new version of google play services in the play store?
来自 site 的最新更新是 2014 年 12 月
Does this mean that the app needs a newer version than the one that is currently installed in the device?
您可以检查设备的 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
}
这是 GooglePlayServicesUtil
的文档: http://developer.android.com/reference/com/google/android/gms/common/GooglePlayServicesUtil.html.
这是他们谈论 "ensuring" 用户安装它的地方: https://developer.android.com/google/play-services/setup.html#ensure
这里取自官方 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;
}
}
中使用它
@Override
protected void onResume() {
super.onResume();
// Verifies the proper version of Google Play Services exists on the device.
PlayServicesUtils.checkGooglePlaySevices(this);
}
请注意,所有当前答案都引用了现在已弃用的 GooglePlayServicesUtil。有关如何执行 Google Play 服务版本兼容性检查的详细信息,请参阅 GooglePlayServicesUtil vs GoogleApiAvailability。
文档已更新,现在很清楚:
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.
我通过更新最新版本的 Youtube 库解决了这个问题:https://developers.google.com/youtube/android/player/downloads
在gradle中:
implementation files('libs/YouTubeAndroidPlayerApi.jar')