将 Google Play Services 更新到版本 18 后,似乎无法再使用 GooglePlayServicesNotAvailableException。这段代码:
try {
MapsInitializer.initialize(ctx);
} catch (GooglePlayServicesNotAvailableException e) {
e.printStackTrace();
}
生成此错误:
Unreachable catch block for GooglePlayServicesNotAvailableException. This exception is never thrown from the try statement body
现在我怎样才能达到同样的结果? 谢谢
最佳答案
现在函数 initialize()
返回一个 ConnectionResult
,因此您可以执行如下操作:
if (MapsInitializer.initialize(ctx) != ConnectionResult.SUCCESS) {
// Handle the error
}
关于android - 谷歌地图 Android API v2 : GooglePlayServicesNotAvailableException not thrown anymore,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24969600/