Sorry for being newbie. I just want to create an app that will get current location thru gps, whether location is change or not.
I can manage to get the location
onCreate code:
map = (MapView) findViewById(R.id.map);
map.setTileSource(TileSourceFactory.MAPNIK);
map.setBuiltInZoomControls(true);
map.setMultiTouchControls(true);
myLocationOverlay = new MyLocationNewOverlay(getApplicationContext(), map);
map.getOverlays().add(myLocationOverlay);
myLocationOverlay.enableMyLocation();
myLocationOverlay.enableFollowLocation();
but cannot implement to get real-time coordinates implemented on onLocationChanged. It will be much appreciated to have a whole source code that will show the solution. I get easily lost in part by part code.
Thank you in advance.
http://developer.android.com/reference/android/location/LocationListener.html
have your activity implement the location listener interface, register the listener with the location service manager.
try {
locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, this);
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,0, 0, this);
}
catch (Exception ex) {
//do something useful here
}
there's a full example here Background service with location listener in android