Hi, Take a look at the following code:
The first class is a locationmanager which holds the current and previous location: public class MyLocationManager implements LocationListener { private Location previousLocation; private Location currentLocation; private LocationManager locationManager; public MyLocationManager (Activity activity) { this.locationManager = (LocationManager) activity.getSystemService(Context.LOCATION_SERVICE); this.locationManager.requestLocationUpdates (LocationManager.GPS_PROVIDER, 0, 0, this); } @Override public void onLocationChanged(Location location) { this.lastLocation = location; Log.v("LocationManager", "Lat: " + location.getLatitude() + " - Lon: " + location.getLongitude()); } @Override public void onProviderDisabled(String provider) {} @Override public void onProviderEnabled(String provider) {} @Override public void onStatusChanged(String provider, int status, Bundle extras) {} } Th second class is the main activity which acts like a server and uses the previous location to do something: public class Example extends Activity { private MyLocationManager myLocationManager; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); myLocationManager = new MyLocationManager(this); while (true) { // do something (like some server functionality) Location loc = myLocationManager.getPreviousLocation(); // do something } } } The problem is that myLocationManager doesn't retreive any updates for the location. I think it has to do with this while-loop that blocks the main-thread by continously executing. And because mylocationmanager is also running in the main thread, he cant't retrieve his location updates. Does somebody know how to deal with this? I think I have to make use of threads somewhere, but I don't know where exactly. Thanks in advance! kind regards, Denzel --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Beginners" group. To post to this group, send email to android-beginners@googlegroups.com To unsubscribe from this group, send email to android-beginners-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en -~----------~----~----~----~------~----~------~--~---