1

我已经添加了google maps v2. 他们使用Google play services. 从评分看来,大多数用户没有更新 Google Play 服务,因此在尝试打开应用程序时会崩溃。

有什么办法可以让部分代码成为谷歌播放服务的库,这样它们就不会崩溃......

很想找到任何解决方案

4

2 回答 2

1

如果用户没有,Google play services您可以显示对话框来获取它

// Getting Google Play availability status
int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getActivity());


//there are other "status" values as well, you can check according to your need

// Showing status
if(status!=ConnectionResult.SUCCESS){ // Google Play Services are not available

    int requestCode = 10;
    ialog dialog = GooglePlayServicesUtil.getErrorDialog(status, getActivity(), requestCode);
    dialog.show();

}else{ // Google Play Services are available 

    // get map and play with it
}

哪里ConnectionResult是:

import com.google.android.gms.common.ConnectionResult;
于 2013-05-25T06:04:40.723 回答
0
public static int isGooglePlayServicesAvailable (Context context)

验证此设备上是否安装并启用了 Google Play 服务,并且此设备上安装的版本不低于此客户端所需的版本。

返回指示是否存在错误的状态代码。ConnectionResult 中可以是以下之一:SUCCESS、SERVICE_MISSING、SERVICE_VERSION_UPDATE_REQUIRED、SERVICE_DISABLED、SERVICE_INVALID。

检查主题下的开发者网站检查 Google Play 服务

https://developer.android.com/training/location/retrieve-current.html

于 2013-05-25T06:19:26.257 回答