SlideShare a Scribd company logo
Location-Based Services
       on Android



                   Jomar Tigcal
       GDG DevFest Bacolod 2012
              November 5, 2012
Jomar Tigcal
● Community Manager of GDG Philippines
● Mobile Apps Developer
● Software Engineer at Stratpoint
  Technologies, Inc.
● One of the developers of Moochfood

                      http://jomar.tigcal.com
                          jomar@tigcal.com
                                @jomartigcal
Moochfood
                   Moochfood      is    an
                   Android     application
                   that allows you to
                   record, rate and share
                   dining experiences.




      http://www.moochfood.com/
Location
Challenges
● Obtaining user location can consume a lot of
  battery
● Getting location takes some time
● Because the user location changes, you
  must account for movement by re-estimating
  user location every so often.
● Location estimates from each source may
  not be accurate.
android.location
              Android provides a location
              framework        that    your
              application can use to
              determine      the    device's
              location and bearing and
              register for updates.

              http://developer.android.
              com/reference/android/locat
              ion/package-summary.html
Android Permissions
● ACCESS_COARSE_LOCATION
  -> Network Provider: cell tower and Wi-Fi
  signals

● ACCESS_FINE_LOCATION
  -> GPS Provider
Android Permissions
Note:
If you are using both NETWORK_PROVIDER
and GPS_PROVIDER, then you need to
request only the ACCESS_FINE_LOCATION
permission, because it includes permission for
both.
Android Location API
● Location
  A class representing a geographic location sensed
  at a particular time.

● LocationManager
  This class provides access to the system location
  services.

● LocationListener
  Interface used for receiving notifications from the
  LocationManager when the location has changed.
Getting User Location




                  Image Source: http://evalblog.com/2011/06/06/where-am-i/
Getting User Location
● Create an instance of LocationManager
  Location locationManager =
  (LocationManager) this.getSystemService
  (Context.LOCATION_SERVICE);
● Check Location Provider
  final boolean gpsEnabled =
  locationManager.isProviderEnabled
  (LocationManager.GPS_PROVIDER);
Getting User Location

● Start listening for location updates
  locationManager.requestLocationUpdates
  (LocationManager.GPS_PROVIDER, 0, 0,
  locationListener);

● Stop listening for location updates
  locationManager.removeUpdates(this);
Getting User Location
Getting User Location
Getting User Location
What's next?
Commonly used APIs




         Image Sources: http://developer.foursquare.com and http://thegreasywiener.com/
Google Places API (https:
  //developers.google.
      com/places/)
Google Places API
● Place Searches return a list of Places based on
  a user's location or search string.
● Place Details requests return more detailed
  information about a specific Place, including user
  reviews.
● Place Actions allow you to supplement the data
  in Google's Places Database with data from your
  application. You can schedule Events, add and
  remove Places, or weight Place rankings from
  user activity with Place Bumps.
Google Places API
● Places Autocomplete can be used to provide
  autocomplete functionality for text-based
  geographic searches, by returning Places as
  you type.
● Query Autocomplete can be used to provide a
  query prediction service for text-based
  geographic searches, by returning suggested
  queries as you type.
Getting API Key
● Go to Google APIs console (http://code.
  google.com/apis/console)
● Create an API Project
● Select Services
● Turn on Places API
Places Search
● Nearby Search
  by location (latitude, longitude)

● Text Search
  by search query
  (e.g. "pizza in Bacolod")
Nearby Search Syntax

Syntax:
https://maps.googleapis.
com/maps/api/place/nearbysearch/output?
parameters

Output: Either json or xml
Nearby Search Required Parameters
● key
  API Key
● location
  latitude, longitude
● radius
  distance in meters, maximum of 50, 000 m
● sensor (true/false)
  if request came from location sensor (GPS)
Nearby Search Optional Parameters
keyword -         content
language -        language code
name        -     name
rankby      -     prominence or distance
*if rankby=distance, radius should not be included

types
pagetoken
Place Search Types
Separated by |

Examples:
food     restaurant   convenience_store
hospital school       grocery_or_supermarket

More at:
https://developers.google.
com/places/documentation/supported_types
Example
● Place Search:
https://maps.googleapis.
com/maps/api/place/nearbysearch/json?
location=loc_here&sensor=true&radius=500&ke
y=key_here
● Type=food
https://maps.googleapis.
com/maps/api/place/nearbysearch/json?
location=loc_here&sensor=true&radius=500&typ
es=food&key=key_here
Foursquare API (https:
//developer.foursquare.
         com)
Foursquare API
Core API: Check in, view their history, see where
their friends are, create tips and lists, search for
and learn more about venues, and access specials
and recommendations.

Real-time API: Venue push API notifies venue
managers when users check in to their venues,
and our user push API notifies developers when
their users check in anywhere.
Foursquare API
Merchant Platform: Allows developers to write
applications that help registered venue owners
manage their foursquare presence and
specials.

Venues Platform: Search for places and access
a wealth of information about them, including
addresses, popularity, tips, and photos.
Foursquare Venues Search
Search Foursquare database and find
information including tips, photos, check-in
counts, and here now

Syntax:

https://api.foursquare.com/v2/venues/search
Venues Search Parameters
Required Parameters:

● ll (latitude, longitude) - user's location
  or
● near (text) - place where to search

● v (YYYYMMDD) indicates that the client is
  up to date as of the specified date
Venues Search Parameters
Optional Parameters:

●   query - name of place to search
●   limit - number of results (max is 50)
●   radius - distance in meters (max is 10,000)
●   categoryId - comma-separated categories to
    limit search
Foursquare Demo
HTTP Request:
https://api.foursquare.com/v2/venues/search?
ll=40.7,-74
&oauth_token=0445ZMNU5XS4JDAURLRE3M
ARL222RVJITL2XBKF0CR1C2EWR&v=20121
102

Android Project:
  * Sample Android Project is available at
  https://github.com/jomartigcal/lbs-android-
  sample
Foursquare Demo
Google Places API Challenge 2012
http://developers.google.com/places/challenge/




  Deadline: November 30, 2012
Foursquare Hack Day Philippines
      http://hackday.webgeek.ph/




       December 1, 2012
Resources
● http://developer.android.
  com/reference/android/location/package-
  summary.html
● http://developer.android.
  com/guide/topics/location/index.html
● https://developers.google.com/places/
● https://developer.foursquare.com
● https://github.com/jomartigcal/lbs-android-
  sample
Questions?




             Image Source: http://www.smoblog.com/
Thank you very much!
Location-Based Services
       on Android



                   Jomar Tigcal
       GDG DevFest Bacolod 2012
              November 5, 2012

More Related Content

PPTX
Android activity lifecycle
PPTX
Notification android
PPTX
Basic android-ppt
PPT
android activity
PDF
Introduction to Android Development
PDF
Android notification
PDF
Android resource
PPTX
Android studio ppt
Android activity lifecycle
Notification android
Basic android-ppt
android activity
Introduction to Android Development
Android notification
Android resource
Android studio ppt

What's hot (20)

PPTX
Android User Interface
PPTX
Introduction to Android and Android Studio
PPTX
Android architecture
PDF
Android Location and Maps
PDF
Android Telephony Manager and SMS
PPT
Intent, Service and BroadcastReciver (2).ppt
PPT
Mobile Application Development With Android
PPT
Android lifecycle
PPTX
Broadcast Receiver
PDF
Introduction to fragments in android
ZIP
Android Application Development
PDF
Android intents
PPTX
Top 11 Mobile App Development Frameworks
PPT
Android Architecture
PPTX
Android app development
PPTX
PPTX
Android application development ppt
PDF
Introduction to flutter
PPTX
Flutter presentation.pptx
PPTX
Android app development ppt
Android User Interface
Introduction to Android and Android Studio
Android architecture
Android Location and Maps
Android Telephony Manager and SMS
Intent, Service and BroadcastReciver (2).ppt
Mobile Application Development With Android
Android lifecycle
Broadcast Receiver
Introduction to fragments in android
Android Application Development
Android intents
Top 11 Mobile App Development Frameworks
Android Architecture
Android app development
Android application development ppt
Introduction to flutter
Flutter presentation.pptx
Android app development ppt
Ad

Viewers also liked (20)

PPTX
Location based reminder
DOCX
Location Tracking of Android Device Based on SMS.
PPTX
Location Based services
PPT
Lecture Slides for Location based Services [Android]
PPTX
Location Based Services - An Overview
PDF
Final Year Project Report on Self Tacit Zone (Location Based Android App)
PPTX
1 location tracking of android device based on sms
PDF
Mobile GPS Tracking
PPT
20 Hot Location-Based Apps and Services You Should Know About
PDF
Location Based Services: Business Model
DOCX
Vehicle tracking system,be computer android report,android project report,gps...
DOC
My Project Report Documentation with Abstract & Snapshots
PPTX
7 Hot Location-Based Apps You Should Know About
PPTX
Bus tracking application in Android
PPTX
Dfd examples
PDF
Location Based Services: Global Market Overview, Deployment Trends and Potent...
PDF
Bus tracking application project report
PDF
Vehicle tracking system using gps and gsm techniques
PPTX
Location Based Services
PPTX
Vehicle Tracking System
Location based reminder
Location Tracking of Android Device Based on SMS.
Location Based services
Lecture Slides for Location based Services [Android]
Location Based Services - An Overview
Final Year Project Report on Self Tacit Zone (Location Based Android App)
1 location tracking of android device based on sms
Mobile GPS Tracking
20 Hot Location-Based Apps and Services You Should Know About
Location Based Services: Business Model
Vehicle tracking system,be computer android report,android project report,gps...
My Project Report Documentation with Abstract & Snapshots
7 Hot Location-Based Apps You Should Know About
Bus tracking application in Android
Dfd examples
Location Based Services: Global Market Overview, Deployment Trends and Potent...
Bus tracking application project report
Vehicle tracking system using gps and gsm techniques
Location Based Services
Vehicle Tracking System
Ad

Similar to Location-Based Services on Android (20)

PDF
Android App Development 04 : Location API
PPT
Android - Android Geocoding and Location based Services
PDF
Mobile Application Development-Lecture 15 & 16.pdf
PPTX
Location based services
PDF
Developing Windows Phone Apps with Maps and Location Services
PPTX
Android location and sensors API
PPTX
Philipp Nagele (Wikitude): What's Next with Wikitude
PPTX
Deep Dive into the ArcGIS Geotrigger Service - Esri DevSummit Dubai 2013
PPTX
Mobile applications chapter 6
PPTX
Location-Based Marketing Application Development Made Easier with GeoSimulator
DOCX
PDF
How to use geolocation in react native apps
PDF
[English] Create Mobile LBS Application Using Maps API
PPTX
MAD Unit 6.pptx
PDF
[Android] Maps, Geocoding and Location-Based Services
PPTX
complete ppt
PDF
Android location based services
PDF
IEEE PROJECT TOPICS & ABSTRACTS BY SOFTRONIICS
PDF
Interview with Developer Jose Luis Arenas regarding Google App Engine & Geosp...
PDF
The GPS Architecture on Android
Android App Development 04 : Location API
Android - Android Geocoding and Location based Services
Mobile Application Development-Lecture 15 & 16.pdf
Location based services
Developing Windows Phone Apps with Maps and Location Services
Android location and sensors API
Philipp Nagele (Wikitude): What's Next with Wikitude
Deep Dive into the ArcGIS Geotrigger Service - Esri DevSummit Dubai 2013
Mobile applications chapter 6
Location-Based Marketing Application Development Made Easier with GeoSimulator
How to use geolocation in react native apps
[English] Create Mobile LBS Application Using Maps API
MAD Unit 6.pptx
[Android] Maps, Geocoding and Location-Based Services
complete ppt
Android location based services
IEEE PROJECT TOPICS & ABSTRACTS BY SOFTRONIICS
Interview with Developer Jose Luis Arenas regarding Google App Engine & Geosp...
The GPS Architecture on Android

More from Jomar Tigcal (8)

PDF
Android Design
PDF
Android Apps Development
PDF
GDG Philippines in 2012
PDF
It's more fun in Android!
PDF
Google+ and the Google+ Platform
PDF
Why go into Android Apps Development
PDF
Introduction to Google Drive API
PDF
Introduction to Google Chrome Extensions Development
Android Design
Android Apps Development
GDG Philippines in 2012
It's more fun in Android!
Google+ and the Google+ Platform
Why go into Android Apps Development
Introduction to Google Drive API
Introduction to Google Chrome Extensions Development

Recently uploaded (20)

PDF
Microsoft Solutions Partner Drive Digital Transformation with D365.pdf
PDF
Web App vs Mobile App What Should You Build First.pdf
PPTX
The various Industrial Revolutions .pptx
PPTX
Chapter 5: Probability Theory and Statistics
PDF
Enhancing emotion recognition model for a student engagement use case through...
PDF
DASA ADMISSION 2024_FirstRound_FirstRank_LastRank.pdf
PPTX
Group 1 Presentation -Planning and Decision Making .pptx
PDF
A novel scalable deep ensemble learning framework for big data classification...
PDF
1 - Historical Antecedents, Social Consideration.pdf
PDF
August Patch Tuesday
PPT
What is a Computer? Input Devices /output devices
PDF
WOOl fibre morphology and structure.pdf for textiles
PDF
STKI Israel Market Study 2025 version august
PDF
A contest of sentiment analysis: k-nearest neighbor versus neural network
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Architecture types and enterprise applications.pdf
PPTX
OMC Textile Division Presentation 2021.pptx
PDF
Transform Your ITIL® 4 & ITSM Strategy with AI in 2025.pdf
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Microsoft Solutions Partner Drive Digital Transformation with D365.pdf
Web App vs Mobile App What Should You Build First.pdf
The various Industrial Revolutions .pptx
Chapter 5: Probability Theory and Statistics
Enhancing emotion recognition model for a student engagement use case through...
DASA ADMISSION 2024_FirstRound_FirstRank_LastRank.pdf
Group 1 Presentation -Planning and Decision Making .pptx
A novel scalable deep ensemble learning framework for big data classification...
1 - Historical Antecedents, Social Consideration.pdf
August Patch Tuesday
What is a Computer? Input Devices /output devices
WOOl fibre morphology and structure.pdf for textiles
STKI Israel Market Study 2025 version august
A contest of sentiment analysis: k-nearest neighbor versus neural network
Assigned Numbers - 2025 - Bluetooth® Document
Programs and apps: productivity, graphics, security and other tools
Architecture types and enterprise applications.pdf
OMC Textile Division Presentation 2021.pptx
Transform Your ITIL® 4 & ITSM Strategy with AI in 2025.pdf
Profit Center Accounting in SAP S/4HANA, S4F28 Col11

Location-Based Services on Android

  • 1. Location-Based Services on Android Jomar Tigcal GDG DevFest Bacolod 2012 November 5, 2012
  • 2. Jomar Tigcal ● Community Manager of GDG Philippines ● Mobile Apps Developer ● Software Engineer at Stratpoint Technologies, Inc. ● One of the developers of Moochfood http://jomar.tigcal.com jomar@tigcal.com @jomartigcal
  • 3. Moochfood Moochfood is an Android application that allows you to record, rate and share dining experiences. http://www.moochfood.com/
  • 5. Challenges ● Obtaining user location can consume a lot of battery ● Getting location takes some time ● Because the user location changes, you must account for movement by re-estimating user location every so often. ● Location estimates from each source may not be accurate.
  • 6. android.location Android provides a location framework that your application can use to determine the device's location and bearing and register for updates. http://developer.android. com/reference/android/locat ion/package-summary.html
  • 7. Android Permissions ● ACCESS_COARSE_LOCATION -> Network Provider: cell tower and Wi-Fi signals ● ACCESS_FINE_LOCATION -> GPS Provider
  • 8. Android Permissions Note: If you are using both NETWORK_PROVIDER and GPS_PROVIDER, then you need to request only the ACCESS_FINE_LOCATION permission, because it includes permission for both.
  • 9. Android Location API ● Location A class representing a geographic location sensed at a particular time. ● LocationManager This class provides access to the system location services. ● LocationListener Interface used for receiving notifications from the LocationManager when the location has changed.
  • 10. Getting User Location Image Source: http://evalblog.com/2011/06/06/where-am-i/
  • 11. Getting User Location ● Create an instance of LocationManager Location locationManager = (LocationManager) this.getSystemService (Context.LOCATION_SERVICE); ● Check Location Provider final boolean gpsEnabled = locationManager.isProviderEnabled (LocationManager.GPS_PROVIDER);
  • 12. Getting User Location ● Start listening for location updates locationManager.requestLocationUpdates (LocationManager.GPS_PROVIDER, 0, 0, locationListener); ● Stop listening for location updates locationManager.removeUpdates(this);
  • 17. Commonly used APIs Image Sources: http://developer.foursquare.com and http://thegreasywiener.com/
  • 18. Google Places API (https: //developers.google. com/places/)
  • 19. Google Places API ● Place Searches return a list of Places based on a user's location or search string. ● Place Details requests return more detailed information about a specific Place, including user reviews. ● Place Actions allow you to supplement the data in Google's Places Database with data from your application. You can schedule Events, add and remove Places, or weight Place rankings from user activity with Place Bumps.
  • 20. Google Places API ● Places Autocomplete can be used to provide autocomplete functionality for text-based geographic searches, by returning Places as you type. ● Query Autocomplete can be used to provide a query prediction service for text-based geographic searches, by returning suggested queries as you type.
  • 21. Getting API Key ● Go to Google APIs console (http://code. google.com/apis/console) ● Create an API Project ● Select Services ● Turn on Places API
  • 22. Places Search ● Nearby Search by location (latitude, longitude) ● Text Search by search query (e.g. "pizza in Bacolod")
  • 24. Nearby Search Required Parameters ● key API Key ● location latitude, longitude ● radius distance in meters, maximum of 50, 000 m ● sensor (true/false) if request came from location sensor (GPS)
  • 25. Nearby Search Optional Parameters keyword - content language - language code name - name rankby - prominence or distance *if rankby=distance, radius should not be included types pagetoken
  • 26. Place Search Types Separated by | Examples: food restaurant convenience_store hospital school grocery_or_supermarket More at: https://developers.google. com/places/documentation/supported_types
  • 27. Example ● Place Search: https://maps.googleapis. com/maps/api/place/nearbysearch/json? location=loc_here&sensor=true&radius=500&ke y=key_here ● Type=food https://maps.googleapis. com/maps/api/place/nearbysearch/json? location=loc_here&sensor=true&radius=500&typ es=food&key=key_here
  • 29. Foursquare API Core API: Check in, view their history, see where their friends are, create tips and lists, search for and learn more about venues, and access specials and recommendations. Real-time API: Venue push API notifies venue managers when users check in to their venues, and our user push API notifies developers when their users check in anywhere.
  • 30. Foursquare API Merchant Platform: Allows developers to write applications that help registered venue owners manage their foursquare presence and specials. Venues Platform: Search for places and access a wealth of information about them, including addresses, popularity, tips, and photos.
  • 31. Foursquare Venues Search Search Foursquare database and find information including tips, photos, check-in counts, and here now Syntax: https://api.foursquare.com/v2/venues/search
  • 32. Venues Search Parameters Required Parameters: ● ll (latitude, longitude) - user's location or ● near (text) - place where to search ● v (YYYYMMDD) indicates that the client is up to date as of the specified date
  • 33. Venues Search Parameters Optional Parameters: ● query - name of place to search ● limit - number of results (max is 50) ● radius - distance in meters (max is 10,000) ● categoryId - comma-separated categories to limit search
  • 36. Google Places API Challenge 2012 http://developers.google.com/places/challenge/ Deadline: November 30, 2012
  • 37. Foursquare Hack Day Philippines http://hackday.webgeek.ph/ December 1, 2012
  • 38. Resources ● http://developer.android. com/reference/android/location/package- summary.html ● http://developer.android. com/guide/topics/location/index.html ● https://developers.google.com/places/ ● https://developer.foursquare.com ● https://github.com/jomartigcal/lbs-android- sample
  • 39. Questions? Image Source: http://www.smoblog.com/
  • 40. Thank you very much!
  • 41. Location-Based Services on Android Jomar Tigcal GDG DevFest Bacolod 2012 November 5, 2012