如何检查Google Play服务是否是最新的

时间:2014-12-22 14:02:04

标签: android google-play-services

在我的应用中,我需要使用Google Play服务的方式,因此首先我必须检查用户手机中是否有Google Play服务

这是我尝试过的:

int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable( getApplicationContext() );
if(status == ConnectionResult.SUCCESS) {
    //alarm to go and install Google Play Services
}

之后如果已经安装,我需要检查用户手机上的Google Play服务版本是否是最新的 我该怎么做 ?? 任何想法?

1 个答案:

答案 0 :(得分:2)

如果您从here

查看参考

它会显示 isGooglePlayServicesAvailable 会返回代码,该代码的开头是 SERVICE_VERSION_UPDATE_REQUIRED

所以你可以做这些事情

int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable( getApplicationContext() );
if(status == ConnectionResult.SUCCESS) {
    //alarm to go and install Google Play Services
}else if(status == ConnectionResult.SERVICE_VERSION_UPDATE_REQUIRED){
   Toast.makeText(context,"please udpate your google play service",Toast.LENGTH_SHORT).show
}