【发布时间】:2014-06-16 17:44:02
【问题描述】:
我找到了解决办法。地图可能还没有初始化,在生命周期的后期尝试getMap(),比如onResume()
我的代码是
protected void onResume() {
super.onResume();
int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getApplicationContext());
if (resultCode == ConnectionResult.SUCCESS){
Toast.makeText(getApplicationContext(),
"isGooglePlayServicesAvailable SUCCESS",
Toast.LENGTH_LONG).show();
if(gMap == null){
gMap = mMapView.getMap();
if(gMap != null){
gMap.setMyLocationEnabled(true);
gMap.setMapType(GoogleMap.MAP_TYPE_HYBRID);
}else{
Toast.makeText(getApplicationContext(),
"cannot getMap!",
Toast.LENGTH_LONG).show();
}
}
}else{
GooglePlayServicesUtil.getErrorDialog(resultCode, this, RQS_GooglePlayServices);
}
}
【问题讨论】:
-
请发布完整代码以提供解决方案..
标签: android google-maps google-maps-markers