Can't finish a MapActivity

240 Views Asked by At

I've created this activity for an android application:

http://developer.android.com/resources/tutorials/views/hello-mapview.html

Now I want to finish the MapActivity OnTouch, but I don't know how to do it.

I've tried this, on the HelloItemizedOverlay class but don't work: (I'm using the mapView to get the coordinates of a GeoPoint!)

public boolean onTouchEvent(MotionEvent event, MapView mapView) {
      finish();
}

Many thanks!

1

There are 1 best solutions below

1
On BEST ANSWER

Pass the Activity to the HelloItemizedOverlay and call finish() on the activity.

private Activity mActivity;

 public HelloItemizedOverlay(Drawable defaultMarker, Activity activity) {
  super(boundCenterBottom(defaultMarker));
  mActivity = activity;
 }

 public boolean onTouchEvent(MotionEvent event, MapView mapView) {
      mActivity.finish(); 
 }