Download presentation
Presentation is loading. Please wait.
Published byBertram Hines Modified over 9 years ago
1
LocationListener in Android Nasrullah
2
The LocationManager provides access to the system location services The LocationListener is used for receiving notifications from the LocationManager when the location has changed
3
Gps behaviour When you enable the GPS on your Android phone, the GPS doesn’t immediately starts retrieving your location. No GPS icon will be shown in the title bar, unless a certain application (like Google Maps) triggers it to request a location. That being said, when you call requestLocationUpdates, you’ll start noticing the GPS icon. This means the GPS is trying to pinpoint your location. When you see the GPS icon on your phone, you know that it’s consuming your battery power. The GPS will try to pinpoint your location, by tracking whatever available sattelites, and your location listener will be notified of location updates. Going back to the minTime and minDistance in the requestLocationUpdates call, you’ll notice the following in the JavaDoc : The frequency of notification may be controlled using the minTime and minDistance parameters. If minTime is greater than 0, the LocationManager could potentially rest for minTime milliseconds between location updates to conserve power. If minDistance is greater than 0, a location will only be broadcasted if the device moves by minDistance meters. To obtain notifications as frequently as possible, set both parameters to 0. Important to understand here is that setting the frequency (minTime) to 35 does not mean that your locationListener will only kick-in once every 35 seconds. The minimum time interval for notifications, in milliseconds is only used as a hint to conserve power, and actual time between location updates may be greater or lesser than this value
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.