I am currently developing an android app that requires GPS module.
I have code like this:
LocationManager mlocManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
LocationListener mlocListener = new MyLocationListener();
mlocManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, mlocListener);
public class MyLocationListener implements LocationListener
{
public void onLocationChanged(Location location)
{
if (location != null) {
double gpsLatitude = location.getLatitude();
double gpsLongitude = location.getLongitude();
float acc = (float) (location.getAccuracy());
Date gpsDate = new Date(location.getTime());
}
}
}
1). I have searched what getAccuracy() returns. I found that it returns accuracy in meters. Is this correct ?
2). I want to retrieve the gpsDate from another button onClick. This LocationListener triggers when the gps detects movement or how ? Imagine that the user moves with the device around, stops and presses a button. On this press I need to save the date from gps to a file. How do I get this date ?
Thank you all for your time.