android


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.

Related Links

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

Categories

HOME
phpword
oracle12c
localization
checkstyle
webdriver
angular-formly
oracle-apex-5
package
aws-cli
google-apps
telegram-bot
google-admin-sdk
bing-maps
sendgrid-api-v3
pcl-crypto
mautic
emoji
angular-dart
onedrive-api
symbol
keytool
atlassian-stash
google-container-registry
sigma.js
microsoft-ocr
springfox
fat
delimiter
sqsh
event-flow
jett
android-gridview
login-script
twos-complement
reactjs.net
least-squares
odroid
apns-php
news
hackintosh
magento-1.9.3
signal-strength
twilio-click-to-call
scalding
java-bytecode-asm
dt
reshape
jtree
stripe-connect
angular2-testing
grails-plugin
vulcanize
jboss-tools
dynatree
java-money
terracotta
r-package
forwarding
fuelcms
page.js
sony-lifelog-api
typemock
sha512
nutiteq
boost-program-options
android-vibration
browserify-shim
sql-scripts
strawberry-perl
jama
jjaql
authlogic
eclipse-kepler
model-driven-development
beaker-testing
poker
superscrollorama
mysql-error-2013
alice
device-width
qi4j
listitem
google-maps-mobile
luajava
binomial-heap
zend-rest
cfwindow
windows-identity
fdf
sqlobject
change-management

Resources

Encrypt Message