_Android Activity Not Launching MapActivity
I have decided to play around with Android and started out using the Google API for Maps. My goal is to create an app that has a tab view that you can tab through some info and on the tabs there will be a button to launch the Google Map to show the location of the point of interest and show where you are and provide directions. I have the tab view working great but when I try to fire off an event for the MapActivity that is where it fails.
If I create my own MapActivity project it works fine, but when I include the class in my tab project it fails.
Here is what I have:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.location_tab);
...
Button btnMap = (Button) findViewById(R.id.btnMapview);
btnMap.setOnClickListener(mMapListener);
...
}
And my Listener
private OnClickListener mMapListener = new OnClickListener() {
public void onClick(View v) {
Intent mapIntent = new Intent(getApplicationContext(),LocationMap.class);
startActivity(mapIntent);
}
};
And here is my Map Class:
public class LocationMap extends MapActivity {
MapView mapView;
MapController mc;
GeoPoint p;
@Override
protected boolean isRouteDisplayed() {
return false;
}
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mapView = (MapView) findViewById(R.id.myMapView);
mapView.setBuiltInZoomControls(true);
mc = mapView.getController();
String coordinates[] = {"40.750386", "-73.976773"};
double lat = Double.parseDouble(coordinates[0]);
double lng = Double.parseDouble(coordinates[1]);
p = new GeoPoint(
(int) (lat * 1E6),
(int) (lng * 1E6));
mc.animateTo(p);
mc.setZoom(17);
mapView.invalidate();
}
}
I get a force close each time I click the button. I have swapped out my LocationMap.class with a standard activity class and that works fine. I have put my LocationMap class in it’s own project and that works fine as well, but together…no dice.
Any thoughts? Here is my StackOverflow post





