Download presentation
Presentation is loading. Please wait.
Published byAlbert Williams Modified over 8 years ago
1
Sensors – Part 2 SE 395/595
2
Location in Android LocationManager class – Configure providers and their listeners LocationListener class – Handles update of location from a provider Location class – Presentation of a location udate manifest.xml – Permissions enabled here
3
Location Manager Obtain a list of all providers Retrieve the best provider given some criteria Request last known location for a provider Add standard location listeners – Also NMEA listeners, provides time stamp and NMEA string – A variety of listener options exist
4
Provider Types GPS_PROVIDER – When enabled provides location fixes via GPS – Requires ACCESS_FINE_LOCATION PERMISSION – Extra data: number of satellites NETWORK_PROVIDER – When enabled provides location fixes via network location of available cell towers and/or access points PASSIVE_PROVIDER – Does not request provider enabled – Returns location fixes being provided to other requesting entities – Requires ACCESS_FINE_LOCATION
5
Location Provider Similar to Sensor class – Name, power requirements, monetary cost to use, meets criteria (more on that later), requires cell, requires network, etc. – Doesn’t really provide access to date, but really details on the system.
6
Location Listener onStatusChanged(String provider, int status, Bundle extras) onProviderEnabled(String provider) onProviderDisabled(String provider) onLocationChanged(location)
7
Registering location updates Several possible options to request one or multiple location listeners requestLocationUpdates (String provider, long minTime, float minDistance, LocationListener listener) Where, minTime – minimum time interval between updates minDistance – minimum distance between updates (meters) Listener – LocationListener to listen for these changes
8
Location class Stores location objects – Not just for location sensor handling getLatitude getLongitude getBearing getSpeed getTime getAccuracy() etc.
9
Permissions Add to manifest.xml as needed above:
10
References API Reference – http://developer.android.com/reference/android/l ocation/LocationListener.html http://developer.android.com/reference/android/l ocation/LocationListener.html – http://developer.android.com/reference/android/l ocation/LocationManager.html http://developer.android.com/reference/android/l ocation/LocationManager.html – http://developer.android.com/reference/android/l ocation/Location.html http://developer.android.com/reference/android/l ocation/Location.html
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.