SlideShare a Scribd company logo
1 of 23
Android Programming




         Lesson 8
 Maps, Geocoding and
Location-Based Services
       NGUYEN The Linh
Android Programming


Contents


      1    Location-Based Services

      2    Gecoding

      3    Maps


      4    Exercise 8




                         2
Android Programming


Maps, Geocoding and LBS




         Location-Based Services




                   3
Android Programming


Using Location-Based Services

 Location-based services (LBS) is an umbrella term
  used to describe the different technologies used to
  find the device’s current location. The two main LBS
  elements are:
    LocationManager: Provides hooks to the location-based services.
    LocationProviders: Each of which represents a different location
     finding technology used to determine the device’s current location.




                                  4
Android Programming


Setting up the Emulator with Test Providers

 Location-based services are dependant on device
  hardware for finding the current location. When
  developing and testing with the emulator, your
  hardware is virtualized, and you’re likely to stay in
  pretty much the same location.

 Use the Location Controls available from the DDMS
  perspective in Eclipse to push location changes
  directly into the test GPS_PROVIDER.



                            5
Android Programming


Setting up the Emulator with Test Providers




                     6
Android Programming


Selecting a Location Provider

 Depending on the device, there may be several
  technologies that Android can use to determine the
  current location. Each technology, or Location
  Provider, will offer different capabilities including
  power consumption, monetary cost, accuracy, and the
  ability to determine altitude, speed, or heading
  information.




                          7
Android Programming


Finding the Available Providers

 The LocationManager class includes static string
  constants that return the provider name for the two
  most common Location Providers:
    LocationManager.GPS_PROVIDER
    LocationManager.NETWORK_PROVIDER
 To get a list of names for all the providers available on
  the device, call getProviders, using a Boolean to
  indicate if you want all, or only the enabled, providers
  to be returned:



                            8
Android Programming


Finding Providers Based on Criteria

 In most scenarios, it’s unlikely that you will want to
  explicitly choose the Location Provider to use. More
  commonly, you’ll specify the requirements that a
  provider must meet and let Android determine the
  best technology to use.

 Use the Criteria class to dictate the requirements of a
  provider in terms of accuracy (fine or coarse), power
  use (low, medium, high), cost, and the ability to
  return values for altitude, speed.


                            9
Android Programming


Finding Providers Based on Criteria




                     10
Android Programming


Finding Your Location

 Before you can use the Location Manager, you need
  to add one or more uses-permission tags to your
  manifest to support access to the LBS hardware.



 You can find the last location fix determined by a
  particular Location Provider using the
  getLastKnownLocation method




                           11
Android Programming


Maps, Geocoding and LBS




               Geocoding




                   12
Android Programming


Reverse Geocoding




                    13
Android Programming


Forward Geocoding

 Forward geocoding (or just geocoding) determines
  map coordinates for a given location.
 To do a forward-geocoding lookup, call
  getFromLocationName on a Geocoder instance. Pass in
  the location you want the coordinates for and the
  maximum number of results to return, as shown in the
  snippet below:




                         14
Android Programming


Maps, Geocoding and LBS




                  Maps




                   15
Android Programming


Introducing MapView and MapActivity

 MapView is the actual Map View (control).
 MapActivity is the base class you extend to create a
  new Activity that can include a Map View. The
  MapActivity class handles the application life cycle
  and background service management required for
  displaying maps. As a result, you can only use a
  MapView within MapActivity-derived Activities.
 Overlay is the class used to annotate your maps. Using
  Overlays, you can use a Canvas to draw onto any
  number of layers that are displayed on top of a Map
  View.

                          16
Android Programming


Introducing MapView and MapActivity

 MapController is used to control the map, allowing you
  to set the center location and zoom levels.

 MyLocationOverlay is a special overlay that can be
  used to display the current position and orientation of
  the device.

 ItemizedOverlays and OverlayItems are used together
  to let you create a layer of map markers, displayed
  using drawable with associated text.

                           17
Android Programming


Creating a Map-Based Activity

 The Android map library is not a standard package; as
  an optional API, it must be explicitly included in the
  application manifest before it can be used. Add the
  library to your manifest using a uses-library tag
  within the application node, as shown in the XML
  snippet below:




                          18
Android Programming


Creating a Map-Based Activity

 Google Maps downloads the map tiles on demand; as a
  result, it implicitly requires permission to use the
  Internet. To see map tiles in your Map View, you need
  to add a uses-permission tag to your application
  manifest for android.permission.INTERNET, as shown
  below:




                         19
Android Programming


Creating a Map-Based Activity




                    20
Android Programming


Creating a Map-Based Activity




                    21
Android Programming


Exercise 8




             22
Android Programming

More Related Content

What's hot

Introduction to MapReduce | MapReduce Architecture | MapReduce Fundamentals
Introduction to MapReduce | MapReduce Architecture | MapReduce FundamentalsIntroduction to MapReduce | MapReduce Architecture | MapReduce Fundamentals
Introduction to MapReduce | MapReduce Architecture | MapReduce Fundamentals
Skillspeed
 

What's hot (20)

sutherland- Hodgeman Polygon clipping
sutherland- Hodgeman Polygon clippingsutherland- Hodgeman Polygon clipping
sutherland- Hodgeman Polygon clipping
 
Learn react-js
Learn react-jsLearn react-js
Learn react-js
 
Map reduce prashant
Map reduce prashantMap reduce prashant
Map reduce prashant
 
CSS Grid vs. Flexbox
CSS Grid vs. FlexboxCSS Grid vs. Flexbox
CSS Grid vs. Flexbox
 
Postgres vs Mongo / Олег Бартунов (Postgres Professional)
Postgres vs Mongo / Олег Бартунов (Postgres Professional)Postgres vs Mongo / Олег Бартунов (Postgres Professional)
Postgres vs Mongo / Олег Бартунов (Postgres Professional)
 
Json
JsonJson
Json
 
Css Ppt
Css PptCss Ppt
Css Ppt
 
Object Oriented Programming In JavaScript
Object Oriented Programming In JavaScriptObject Oriented Programming In JavaScript
Object Oriented Programming In JavaScript
 
Introduction to MapReduce | MapReduce Architecture | MapReduce Fundamentals
Introduction to MapReduce | MapReduce Architecture | MapReduce FundamentalsIntroduction to MapReduce | MapReduce Architecture | MapReduce Fundamentals
Introduction to MapReduce | MapReduce Architecture | MapReduce Fundamentals
 
Introduction to xml
Introduction to xmlIntroduction to xml
Introduction to xml
 
WEB I - 01 - Introduction to Web Development
WEB I - 01 - Introduction to Web DevelopmentWEB I - 01 - Introduction to Web Development
WEB I - 01 - Introduction to Web Development
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
 
Function overloading(c++)
Function overloading(c++)Function overloading(c++)
Function overloading(c++)
 
javascript objects
javascript objectsjavascript objects
javascript objects
 
Fragment
Fragment Fragment
Fragment
 
Introduction to programming using Visual Basic 6
Introduction to programming using Visual Basic 6Introduction to programming using Visual Basic 6
Introduction to programming using Visual Basic 6
 
Html presentation
Html presentationHtml presentation
Html presentation
 
Reactjs
Reactjs Reactjs
Reactjs
 
Histogram Processing
Histogram ProcessingHistogram Processing
Histogram Processing
 
screen output and keyboard input in js
screen output and keyboard input in jsscreen output and keyboard input in js
screen output and keyboard input in js
 

Similar to [Android] Maps, Geocoding and Location-Based Services

Mobile Application Development-Lecture 15 & 16.pdf
Mobile Application Development-Lecture 15 & 16.pdfMobile Application Development-Lecture 15 & 16.pdf
Mobile Application Development-Lecture 15 & 16.pdf
AbdullahMunir32
 
Android App Development 04 : Location API
Android App Development 04 : Location APIAndroid App Development 04 : Location API
Android App Development 04 : Location API
Anuchit Chalothorn
 
Location based services 10
Location based services   10Location based services   10
Location based services 10
Michael Shrove
 
Land vehicle tracking system using java on android platform
Land vehicle tracking system using java on android platformLand vehicle tracking system using java on android platform
Land vehicle tracking system using java on android platform
Alexander Decker
 
Maps API on_mobile_dev_festbangkok
Maps API on_mobile_dev_festbangkokMaps API on_mobile_dev_festbangkok
Maps API on_mobile_dev_festbangkok
ss318
 

Similar to [Android] Maps, Geocoding and Location-Based Services (20)

Mobile Application Development-Lecture 15 & 16.pdf
Mobile Application Development-Lecture 15 & 16.pdfMobile Application Development-Lecture 15 & 16.pdf
Mobile Application Development-Lecture 15 & 16.pdf
 
Android App Development 04 : Location API
Android App Development 04 : Location APIAndroid App Development 04 : Location API
Android App Development 04 : Location API
 
Location based services
Location based servicesLocation based services
Location based services
 
Android - Android Geocoding and Location based Services
Android - Android Geocoding and Location based ServicesAndroid - Android Geocoding and Location based Services
Android - Android Geocoding and Location based Services
 
Location based services 10
Location based services   10Location based services   10
Location based services 10
 
Android Rally: Google Maps with LBS
Android Rally: Google Maps with LBSAndroid Rally: Google Maps with LBS
Android Rally: Google Maps with LBS
 
MAD Unit 6.pptx
MAD Unit 6.pptxMAD Unit 6.pptx
MAD Unit 6.pptx
 
All about android
All about androidAll about android
All about android
 
International Journal of Engineering Research and Development
International Journal of Engineering Research and DevelopmentInternational Journal of Engineering Research and Development
International Journal of Engineering Research and Development
 
Android the future
Android  the futureAndroid  the future
Android the future
 
Land vehicle tracking system using java on android platform
Land vehicle tracking system using java on android platformLand vehicle tracking system using java on android platform
Land vehicle tracking system using java on android platform
 
google platform.pptx
google platform.pptxgoogle platform.pptx
google platform.pptx
 
Android application for gps
Android application for gpsAndroid application for gps
Android application for gps
 
Geo location based augmented reality application
Geo location based augmented reality applicationGeo location based augmented reality application
Geo location based augmented reality application
 
THE DESIGN IN MOBILE AND WEB PLATFORM OF THE LOCATION IDENTIFICATION APPLICAT...
THE DESIGN IN MOBILE AND WEB PLATFORM OF THE LOCATION IDENTIFICATION APPLICAT...THE DESIGN IN MOBILE AND WEB PLATFORM OF THE LOCATION IDENTIFICATION APPLICAT...
THE DESIGN IN MOBILE AND WEB PLATFORM OF THE LOCATION IDENTIFICATION APPLICAT...
 
Maps API on_mobile_dev_festbangkok
Maps API on_mobile_dev_festbangkokMaps API on_mobile_dev_festbangkok
Maps API on_mobile_dev_festbangkok
 
Location-Based Services on Android
Location-Based Services on AndroidLocation-Based Services on Android
Location-Based Services on Android
 
Jaipur Bus Finder - An Android-based Application
Jaipur Bus Finder - An Android-based ApplicationJaipur Bus Finder - An Android-based Application
Jaipur Bus Finder - An Android-based Application
 
Jaipur Bus Finder - An Android-based Application
Jaipur Bus Finder - An Android-based ApplicationJaipur Bus Finder - An Android-based Application
Jaipur Bus Finder - An Android-based Application
 
Android app developers in bangalore- thorsignia
Android app developers in bangalore- thorsigniaAndroid app developers in bangalore- thorsignia
Android app developers in bangalore- thorsignia
 

More from Nikmesoft Ltd

More from Nikmesoft Ltd (18)

[iOS] Networking
[iOS] Networking[iOS] Networking
[iOS] Networking
 
[iOS] Data Storage
[iOS] Data Storage[iOS] Data Storage
[iOS] Data Storage
 
[iOS] Multiple Background Threads
[iOS] Multiple Background Threads[iOS] Multiple Background Threads
[iOS] Multiple Background Threads
 
[iOS] Navigation
[iOS] Navigation[iOS] Navigation
[iOS] Navigation
 
[iOS] Basic UI Elements
[iOS] Basic UI Elements[iOS] Basic UI Elements
[iOS] Basic UI Elements
 
[iOS] Introduction to iOS Programming
[iOS] Introduction to iOS Programming[iOS] Introduction to iOS Programming
[iOS] Introduction to iOS Programming
 
[Android] Multimedia Programming
[Android] Multimedia Programming[Android] Multimedia Programming
[Android] Multimedia Programming
 
[Android] Android Animation
[Android] Android Animation[Android] Android Animation
[Android] Android Animation
 
[Android] 2D Graphics
[Android] 2D Graphics[Android] 2D Graphics
[Android] 2D Graphics
 
[Android] Services and Broadcast Receivers
[Android] Services and Broadcast Receivers[Android] Services and Broadcast Receivers
[Android] Services and Broadcast Receivers
 
[Android] Web services
[Android] Web services[Android] Web services
[Android] Web services
 
[Android] Multiple Background Threads
[Android] Multiple Background Threads[Android] Multiple Background Threads
[Android] Multiple Background Threads
 
[Android] Data Storage
[Android] Data Storage[Android] Data Storage
[Android] Data Storage
 
[Android] Intent and Activity
[Android] Intent and Activity[Android] Intent and Activity
[Android] Intent and Activity
 
[Android] Widget Event Handling
[Android] Widget Event Handling[Android] Widget Event Handling
[Android] Widget Event Handling
 
[Android] Using Selection Widgets
[Android] Using Selection Widgets[Android] Using Selection Widgets
[Android] Using Selection Widgets
 
[Android] Basic Widgets and Containers
[Android] Basic Widgets and Containers[Android] Basic Widgets and Containers
[Android] Basic Widgets and Containers
 
[Android] Introduction to Android Programming
[Android] Introduction to Android Programming[Android] Introduction to Android Programming
[Android] Introduction to Android Programming
 

Recently uploaded

Recently uploaded (20)

Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 

[Android] Maps, Geocoding and Location-Based Services

  • 1. Android Programming Lesson 8 Maps, Geocoding and Location-Based Services NGUYEN The Linh
  • 2. Android Programming Contents 1 Location-Based Services 2 Gecoding 3 Maps 4 Exercise 8 2
  • 3. Android Programming Maps, Geocoding and LBS Location-Based Services 3
  • 4. Android Programming Using Location-Based Services  Location-based services (LBS) is an umbrella term used to describe the different technologies used to find the device’s current location. The two main LBS elements are:  LocationManager: Provides hooks to the location-based services.  LocationProviders: Each of which represents a different location finding technology used to determine the device’s current location. 4
  • 5. Android Programming Setting up the Emulator with Test Providers  Location-based services are dependant on device hardware for finding the current location. When developing and testing with the emulator, your hardware is virtualized, and you’re likely to stay in pretty much the same location.  Use the Location Controls available from the DDMS perspective in Eclipse to push location changes directly into the test GPS_PROVIDER. 5
  • 6. Android Programming Setting up the Emulator with Test Providers 6
  • 7. Android Programming Selecting a Location Provider  Depending on the device, there may be several technologies that Android can use to determine the current location. Each technology, or Location Provider, will offer different capabilities including power consumption, monetary cost, accuracy, and the ability to determine altitude, speed, or heading information. 7
  • 8. Android Programming Finding the Available Providers  The LocationManager class includes static string constants that return the provider name for the two most common Location Providers:  LocationManager.GPS_PROVIDER  LocationManager.NETWORK_PROVIDER  To get a list of names for all the providers available on the device, call getProviders, using a Boolean to indicate if you want all, or only the enabled, providers to be returned: 8
  • 9. Android Programming Finding Providers Based on Criteria  In most scenarios, it’s unlikely that you will want to explicitly choose the Location Provider to use. More commonly, you’ll specify the requirements that a provider must meet and let Android determine the best technology to use.  Use the Criteria class to dictate the requirements of a provider in terms of accuracy (fine or coarse), power use (low, medium, high), cost, and the ability to return values for altitude, speed. 9
  • 11. Android Programming Finding Your Location  Before you can use the Location Manager, you need to add one or more uses-permission tags to your manifest to support access to the LBS hardware.  You can find the last location fix determined by a particular Location Provider using the getLastKnownLocation method 11
  • 12. Android Programming Maps, Geocoding and LBS Geocoding 12
  • 14. Android Programming Forward Geocoding  Forward geocoding (or just geocoding) determines map coordinates for a given location.  To do a forward-geocoding lookup, call getFromLocationName on a Geocoder instance. Pass in the location you want the coordinates for and the maximum number of results to return, as shown in the snippet below: 14
  • 16. Android Programming Introducing MapView and MapActivity  MapView is the actual Map View (control).  MapActivity is the base class you extend to create a new Activity that can include a Map View. The MapActivity class handles the application life cycle and background service management required for displaying maps. As a result, you can only use a MapView within MapActivity-derived Activities.  Overlay is the class used to annotate your maps. Using Overlays, you can use a Canvas to draw onto any number of layers that are displayed on top of a Map View. 16
  • 17. Android Programming Introducing MapView and MapActivity  MapController is used to control the map, allowing you to set the center location and zoom levels.  MyLocationOverlay is a special overlay that can be used to display the current position and orientation of the device.  ItemizedOverlays and OverlayItems are used together to let you create a layer of map markers, displayed using drawable with associated text. 17
  • 18. Android Programming Creating a Map-Based Activity  The Android map library is not a standard package; as an optional API, it must be explicitly included in the application manifest before it can be used. Add the library to your manifest using a uses-library tag within the application node, as shown in the XML snippet below: 18
  • 19. Android Programming Creating a Map-Based Activity  Google Maps downloads the map tiles on demand; as a result, it implicitly requires permission to use the Internet. To see map tiles in your Map View, you need to add a uses-permission tag to your application manifest for android.permission.INTERNET, as shown below: 19
  • 20. Android Programming Creating a Map-Based Activity 20
  • 21. Android Programming Creating a Map-Based Activity 21