Location Based Services - Code App, Level Up - [Dec. 2012]

1,318 views

Published on

Presentation about "Location Based Services"

Event: Code App, Level Up
Organizer: EESTEC, FCSE
Date: 12.12.2012, Skopje, Macedonia

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,318
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
64
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Location Based Services - Code App, Level Up - [Dec. 2012]

  1. 1. Location-Based Services Viktor Stojanovski Android Developer @ Seavus 12.12.2012
  2. 2. Agenda  Location API  Android permissions for Location  Location Providers  Obtain device location  Location tips  Demo code  Things to do with Location  Q&A Session
  3. 3. Android Location API  Location   LocationManager   A class representing a geographic location. Provides access to system location services. LocationListener  Interface used for receiveing notifications from the LocationManager when location is changed.
  4. 4. Android permissions for Location  ACCESS_COARSE_LOCATION (NETWORK_PROVIDER)  ACCESS_FINE_LOCATION (GPS_PROVIDER)
  5. 5. NETWORK_PROVIDER vs GPS_PROVIDER  You need to declare the ACCESS_COARSE_LOCATION permission if your application uses a network-based location provider only.  The more accurate GPS requires the ACCESS_FINE_LOCATION permission.  Note that declaring the ACCESS_FINE_LOCATION permission implies ACCESS_COARSE_LOCATION already.
  6. 6. Challenges in Determining User Location  Multitude of location sources   Time   User is moving around Varying accuracy   Getting user information should be fast. Re-Estimate user location   GPS, Cell-ID, Wi-Fi Different sources for location, choose the best accuracy Battery  Don’t kill the battery, the user needs it.
  7. 7. How to obtain device location? 1. Add permissions to AndroidManifest.xml 2. Get a Reference to LocationManager. 3. Define a listener (LocationListener) that responds to location updates. 4. Register the LocationListener with LocationManager to receive location updates. 5. Don’t forget to unregister the listener.
  8. 8. How to obtain device location?
  9. 9. How to obtain device location? type of location provider minimum time interval between location updates, in milliseconds minimum distance between location updates, in me setting both to zero requests location notifications as frequently as possible
  10. 10. Location Criteria
  11. 11. Fresh location information  How to reduce the latency for getting your first location?  Use getLastKnownLocation(provider) from LocationManager.  Is it enough? Which provider should be used for this?  No. All providers.
  12. 12. Fresh location information Iterate through each location provider on the device: Find the most timely and accurate last known location
  13. 13. Verify the Location Provider is Enabled
  14. 14. Get device location Flow Criteria - Power - Accuracy Provider Best provider by criteria Location Manager - Last Known Location - onLocationChanged Location Listener Update user data
  15. 15. Demo Code - MyLocation
  16. 16. Once you got Location, what’s next? 1. Draw maps (Google Maps, Open Street Maps, …) 2. Use third party API’s to get data (example: Google Places, Foursqare, …) 3. Get content from some server (your server) based on device’s location, maybe you are building RSS reader that displays news based on current location.
  17. 17. Google Maps API  Two ways for showing device’s location  Open Intent with latitude and longitude for Google Maps  Standard  VIEW Intent Embed MapActivity in your application  Generate API Key for your device (generate another API Key for production)  Implement everything you need with maps
  18. 18. Google Maps API  The API automatically handles:  Access to Google Maps servers  Data downloading  Displaying maps  Touch gestures  Adding markers, polygons, overlays  Change view of map: (Satellite, Terrain, Traffic, Latitude)
  19. 19. Someone has already done it. Use it!  https://developers.google.com/places/  https://developer.foursquare.com/
  20. 20. Google Places API – Nearby Search  Place Searches  Nearby Search Requests  Text Search Requests  Place Details  Place Actions  Places Autocomplete  Output: either JSON or XML
  21. 21. Foursqaure API  Search for venues   Popularity  Tips   Addresses Photos Access recommendations Example: https://github.com/jomartigcal/lbs-android-sample
  22. 22. Read more … Chapter 13 Chapter 22

×