I have a help desk that receives updates from the location manager every 5 minutes. When onChaged is called, I call a function in my activity to update GeoPoint, which contains my user location. It works great and does what I want. I'm just not sure if itβs better to use something like broadcast receivers. I tried using a broadcast receiver, but it does not work. Is there something wrong with the way I'm doing it now?
I have the following methods in my location service:
public static double getLat() { return lat; } public static double getLng() { return lng; } public void onLocationChanged(Location loc) { lat = (double) (loc.getLatitude()); lng = (double) (loc.getLongitude()); mapview.locationHasChanged(); }
And in my related activities, I have the following:
public static void locationHasChanged() { double myLat = LocationService.getLat(); double myLng = LocationService.getLng(); LocGeo = new GeoPoint( (int) (myLat * 1E6), (int) (myLng * 1E6)); }
source share