need to sync onLocationChanged
i am creating one application which broadcast the location of a user over a web for that i have created a service in which i am using LocationListener and getting updates from onLocationChanged i have set requestLocationUpdates as follows locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 15000, 0, geoHandler); when ever i am getting an update in onLocationChanged i broadcast the location over web. Now the problem is onLocationChanged gets fired too frequently even if it doesn't cross the time limit (that is totally unpredictable) and which in turns trigger my custom function which is broadcasting the location information too frequently. so i dont know how would i sync this process in a proper timely manner like after every 15 seconds the location will be broadcasted over web ,rather then firing it up too frequently
How frequent is the onLocationChanged being called? It is an odd behabiour because when you add a minTime!=0 parameter to : locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, minTime, minDistance, geoHandler) then the listener is not notified only after minTime. After a deeper research I found that minTime is relative. It depends on many factors and therefore your onLocationChanged is not called precisely after minTime. Google recommands to use this parameter for power and battery efficiency. So you should use is as a bigger value, like 1000*60*5 (5 minutes.) If you really need to broadcast your location on each 15 seconds you should bare in mind that GPS pinpoints can not be triggered instantly, it take at least 5-10 seconds (best case). Therefore you have to change your design to something like this: locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, geoHandler) in onLocationChanged just check when was the last time you sent/processed your location, and if the time elapsed is >= 15 sec, broadcast it; Hope it helps you.
locationManager.requestLocationUpdates (String provider, long minTime, float minDistance, LocationListener listener) minTime is minimum time interval between location updates, in milliseconds minDistance is minimum distance between location updates, in meters You are setting minTime as 15seconds but since your minDistance is 0 meters its triggered too frequently. It doesnt have to wait for 15 seconds to pass since a slight change in GPS value triggers a location update. Giving some meters (e.g. 1 or 3) shall increase the interval between updates.
How to achieve wifi display after connected by wifi direct
Copying data from one database table into another database table.
Run time errors in eclipse android application [unfortunately application has stopped]
Android Layout design principles [closed]
Error when build the phonegap android empty project?
multiselect spinner without a dialog
Android Error getting Bitmap from class
Closing android system dialog box automatically
Find time spent on a specific app(or more) in Android
managing multiple row layout in a listview
Location geofencing in a single street
Android http requests
ADB, but not by Eclipse, finds my Android device via USB
Android View width and height have not changed after rotation
I cant keep the text as it is on the screen
Distribute Android Project as a JAR