Google Maps -> MapView -> creation of a constructor -> RuntimeException
I try to write one application for Google Maps.
Tell me, what is my mistake?
If you write like this, all of the works, the card is loaded.
public class TravelMapActivity extends MapActivity {
private MapView mapView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.travel_map_activity);
mapView = (MapView)findViewById(R.id.travelMapView);
}
}
And if you create a constructor, I get these errors here.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.travel_map_activity);
mapView = new MapView(this, getResources().getString(R.string.google_maps_api_key));
}
java.lang.RuntimeException: Unable to start activity ComponentInfo{de.ai.mi.maptrack/de.ai.mi.maptrack.activities.TravelMapActivity}: java.lang.IllegalStateException: You are only allowed to have a single MapView in a MapActivity
Caused by: java.lang.IllegalStateException: You are only allowed to
have a single MapView in a MapActivity
thanks








