0

I am becoming crazy because i must get my position from gps, throught mMyLocationOverlay.getMyLocation() FROM a ListActivity AND NOT MapActivity. GetMyLocation wants context and mapview that i don't have. I tried to take a mapActivity but i get Error to runtime " Caused by: java.lang.IllegalArgumentException: mapView == null " on MyLocationOverlay() constructor . I post my wrong code:

public class ListDeals extends ListActivity
{   

private Events[] events;  
private MyLocationOverlay mMyLocationOverlay;//Riferimento al MyLocationOverlay
private GeoPoint myPoint = null;

@Override
public void onCreate(Bundle savedInstanceState) 
{
  super.onCreate(savedInstanceState);
  String type = this.getIntent().getStringExtra("type"); //legge cosa c'era scritto nell'intent per avere il dato necessario per fare la query al db

  setContentView(R.layout.list_view_x_deals);
  MapView mMapView = (MapView) findViewById(R.id.mapview);
  mMyLocationOverlay = new MyLocationOverlay(this, MyMapView.mapView);
  myPoint = mMyLocationOverlay.getMyLocation();

Where MyMapView.mapView is a "final MapView" created inside the my MapActivity.

Where do i wrong?

SquiresSquire
  • 2,404
  • 4
  • 23
  • 39

1 Answers1

1

you can't use MapView stuff if you don't have a MapView. Use the regular GPS api to get a Location and convert it to a GeoPoint if you want it in that format.

zapl
  • 63,179
  • 10
  • 123
  • 154