Lecture Slides for Location based Services [Android]

4,185 views

Published on

Published in: Technology, Business
0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
4,185
On SlideShare
0
From Embeds
0
Number of Embeds
43
Actions
Shares
0
Downloads
277
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide

Lecture Slides for Location based Services [Android]

  1. 1. Accessing Location-Based services Software Development for Portable Devices BITS Pilani Goa Campus Sem I 2011-12
  2. 2. Applications <ul><li>Mapping </li></ul><ul><li>Directions </li></ul><ul><li>Dynamic chat Application </li></ul><ul><li>“ Geotag” your photos, tweets </li></ul>CS C314 Software Development For Portable Devices
  3. 3. What's common in the above? <ul><li>GPS capability of the phone </li></ul><ul><li>Technologies to identify your location </li></ul><ul><ul><li>GPS </li></ul></ul><ul><ul><li>Cell tower triangulation </li></ul></ul>CS C314 Software Development For Portable Devices
  4. 4. Location based Services (LBS) <ul><li>Two elements of LBS: </li></ul><ul><ul><li>Location manager : provides hooks to lbs </li></ul></ul><ul><ul><li>Location providers : provide current location </li></ul></ul>CS C314 Software Development For Portable Devices
  5. 5. Update location in Emulator <ul><li>In DDMS view, you can set the longitude and latitude  </li></ul><ul><li>Lets see how. </li></ul>CS C314 Software Development For Portable Devices
  6. 6. Location manager <ul><li>You can : </li></ul><ul><ul><li>Find available location providers </li></ul></ul><ul><ul><li>Obtain your current location </li></ul></ul><ul><ul><li>Track movement </li></ul></ul><ul><ul><li>Set proximity alerts for detecting movement into and out of the specified areas </li></ul></ul>CS C314 Software Development For Portable Devices
  7. 7. Location Providers: They know where you are hiding <ul><li>Selecting location provider </li></ul><ul><ul><li>Explicitly – By specifying the name </li></ul></ul><ul><ul><li>Implicitly – By specifying the selection criteria </li></ul></ul>CS C314 Software Development For Portable Devices
  8. 8. Explicit CS C314 Software Development For Portable Devices
  9. 9. User permissions CS C314 Software Development For Portable Devices
  10. 10. Finding yourself <ul><li>hasAltitude() and getAltitude() for Altitude </li></ul><ul><li>hasSpeed() and getSpeed() for Speed </li></ul>CS C314 Software Development For Portable Devices
  11. 11. On the move <ul><li>Why no getMyCurrentLocationNow() ? </li></ul><ul><li>Not all location providers are immediately responsive. </li></ul><ul><li>How to get changes in location reflected in your app? </li></ul><ul><li>Register for location updates! </li></ul>CS C314 Software Development For Portable Devices
  12. 12. requestLocationUpdates ( String  provider, long minTime, float minDistance,  LocationListener  listener) <ul><li>provider : name of location provider </li></ul><ul><li>minTime : how long, in milliseconds, before we might request for a location update </li></ul><ul><li>minDistance : how far,…. in meters </li></ul><ul><li>Listener : name of object of locationListener </li></ul>CS C314 Software Development For Portable Devices
  13. 13. LocationListener CS C314 Software Development For Portable Devices These are the functions provided by the location Listeners
  14. 14. STOP! <ul><li>When not required use removeUpdates() </li></ul><ul><li>If you fail to do this your app will continue getting location updates even after all activities are closed. </li></ul>CS C314 Software Development For Portable Devices
  15. 15. Are we there yet? <ul><li>LocationManager offers addProximityAlert() </li></ul><ul><li>Registers a Pending intent </li></ul><ul><li>addProximityAlert (double latitude, double longitude, float radius, long expiration, PendingIntent intent) </li></ul><ul><li>In case the screen goes to sleep, checks for proximity alerts happen only once every 4 minutes. </li></ul>CS C314 Software Development For Portable Devices
  16. 16. parameters <ul><li>Radius: the radius of the central point of the alert region, in meters </li></ul><ul><li>Expiration: time for this proximity alert, in milliseconds, or -1 to indicate no expiration </li></ul>CS C314 Software Development For Portable Devices
  17. 17. Thank You! CS C314 Software Development For Portable Devices
  18. 18. References <ul><li>Location http://developer.android.com/reference/android/location/Location.html </li></ul><ul><li>Location Manager http://developer.android.com/reference/android/location/LocationManager.html </li></ul><ul><li>Location Provider http://developer.android.com/reference/android/location/LocationProvider.html </li></ul>CS C314 Software Development For Portable Devices

×