I am facing a strange problem. my app shows current location on map when i use WIFI but when i turn WIFI off to check it with GPS, its still shows current location but no map is displayed. it makes map go away and displays current location.can somebody tell me why is it happening? here is my code:
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.main);
mapView = (MapView) findViewById(R.id.mapview);
mapView.setBuiltInZoomControls(true);
mapController = mapView.getController();
me = new MyLocationOverlay(this, mapView);
me.enableMyLocation();
mapView.getOverlays().add(me);
mapController.setZoom(10);
mapView.invalidate();
locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
// locationManager.requestLocationUpdates(
// LocationManager.NETWORK_PROVIDER, 0, 0, new GeoUpdateHandler());
locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
locationManager.requestLocationUpdates(
LocationManager.GPS_PROVIDER, 0, 0, new GeoUpdateHandler());
}
@Override
protected void onDestroy() {
me.disableMyLocation();
super.onDestroy();
}
@Override
protected void onPause() {
super.onPause();
me.disableMyLocation();
}
@Override
protected boolean isRouteDisplayed() {
return false;
}
public class GeoUpdateHandler implements LocationListener {
// @Override
public void onLocationChanged(Location location) {
int lat = (int) (location.getLatitude() * 1E6);
int lng = (int) (location.getLongitude() * 1E6);
GeoPoint point = new GeoPoint(lat, lng);
Toast.makeText(getApplicationContext(), "lat and lng"+lat+lng , Toast.LENGTH_SHORT).show();
mapController.setZoom(18);
mapController.animateTo(point); // mapController.setCenter(point);
mapView.invalidate();
}
GPS is not related to internet but if you want to show MAP so you have a internet….. you can get GPS without internet….. so no need to worry