locationlistener in android nasrullah. the locationmanager provides access to the system location...

3
LocationListener in Android Nasrullah

Upload: bertram-hines

Post on 13-Dec-2015

216 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: LocationListener in Android Nasrullah. The LocationManager provides access to the system location services The LocationListener is used for receiving

LocationListener in Android

Nasrullah

Page 2: LocationListener in Android Nasrullah. The LocationManager provides access to the system location services The LocationListener is used for receiving

• The LocationManager provides access to the system location services

• The LocationListener is used for receiving notifications from the LocationManager when the location has changed

Page 3: LocationListener in Android Nasrullah. The LocationManager provides access to the system location services The LocationListener is used for receiving

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