Reputation: 4594
I'm receving GPS data via DDMS using a KML file in android and I'm using the following code:
public class screen4 extends MapActivity
{
List<GeoPoint> geoPointsArray = new ArrayList<GeoPoint>();
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.screen4);
lm = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
locationListener = new MyLocationListener();
mapView = (MapView) findViewById(R.id.mapview1);
mapView.setBuiltInZoomControls(true);
mc = mapView.getController();
lm.requestLocationUpdates(LocationManager.GPS_PROVIDER,0,0,locationListener);
}
private class MyLocationListener implements LocationListener
{
@Override
public void onLocationChanged(Location loc) {
if (loc != null) {
latitude=(int)(loc.getLatitude()* 1E6);
longitude=(int)(loc.getLongitude()* 1E6);
GeoPoint p = new GeoPoint(latitude,longitude);
geoPointsArray.add(p);
mc.animateTo(p);
mc.setZoom(17);
mapView.invalidate();
mapView.setSatellite(true);
}
}
In onLocationChanged() I retrieve the GPS data and store it in GeoPoint p, what I want to do is to find out the address of the first point(latitude,longitude) and of the last point whose GPS data I retrieve.
My question is: Does my program stay blocked at this line:
lm.requestLocationUpdates(LocationManager.GPS_PROVIDER,0,0,locationListener);
until all the GPS data is retrieved?
In this way I can apply Geocoder for the geoPointsArray(0) and after that for geoPointsArray(maxSize).
My problem is that I don't know how this program works,so I can't really figure out when all my GPS data is retrieved(my geoPointsArray is full) and so where to apply Geocoder.
Question2:
In the moment I start to receive location updates I want to connect to a remote server and send all the GPS data that is stored in geoPointArray to the server. Any idea of where should I start my thread? I have a bunch of code lines but I guess no one is going to read that!
Upvotes: 0
Views: 121
Reputation: 1007534
My question is:does my program stays blocked at this line: lm.requestLocationUpdates(LocationManager.GPS_PROVIDER,0,0,locationListener); until all the GPS data is retrieved????
No. Location updates are asynchronous.
Upvotes: 1