SlideShare a Scribd company logo
1 of 27
Download to read offline
Android	
  Loca+on	
  and	
  Maps	
  

         Jussi	
  Pohjolainen	
  
Loca+on	
  Services	
  and	
  Maps	
  
•  Android	
  provides	
  loca+on	
  framework	
  that	
  
   your	
  app	
  can	
  use	
  to	
  determine	
  	
  
   –  Device’s	
  loca+on	
  
   –  Listening	
  for	
  updates	
  
•  Google	
  maps	
  external	
  library	
  available	
  for	
  
   displaying	
  and	
  managing	
  maps	
  
LOCATION	
  SERVICES	
  
Loca+on	
  Services	
  
•  By	
  using	
  Loca+onManager	
  you	
  are	
  able	
  to	
  
   –  Query	
  for	
  the	
  list	
  of	
  Loca+onProviders	
  for	
  the	
  last	
  
      known	
  loca+on	
  
   –  Register	
  for	
  updates	
  of	
  the	
  user’s	
  current	
  loca+on	
  
   –  Register	
  for	
  given	
  Intent	
  to	
  be	
  fired	
  if	
  the	
  device	
  
      comes	
  within	
  given	
  proximity	
  of	
  given	
  lat/long	
  
Obtaining	
  User	
  Loca+on	
  
•  Loca+on	
  can	
  be	
  determined	
  via	
  GPS	
  and/or	
  
     cell	
  tower	
  +	
  Wi-­‐Fi	
  signals	
  
•  GPS	
  is	
  accurate,	
  but	
  needs	
  outdoors,	
  fix	
  is	
  
     slower	
  and	
  it	
  uses	
  more	
  baQery.	
  	
  
•  To	
  request	
  loca+on,	
  you	
  use	
  Loca+onManager	
  
     -­‐	
  class	
  
	
  
Reques+ng	
  Loca+on	
  Updates	
  
                          Can	
  be	
  also	
  
                         GPS_PROVIDER	
  
                                                    Control	
  
                                                       the	
  
                                                  frequency	
  
                                                     which	
  
                                                    listener	
  
                                                   receives	
  
                                                   updates;	
  
                                                   min	
  +me	
  
                                                   and	
  min	
  
                                                   distance	
  
Reques+ng	
  User	
  Permissions	
  
•  You	
  must	
  add	
  permissions	
  in	
  order	
  to	
  get	
  user	
  
   loca+on	
  

	
  
	
  
•  ACCESS_COARSE_LOCATION	
  
    –  If	
  you	
  use	
  NETWORK_PROVIDER	
  
•  ACCESS_FINE_LOCATION	
  
    –  If	
  you	
  use	
  GPS_PROVIDER	
  or	
  NETWORK_PROVIDER	
  
Ge]ng	
  Last	
  Known	
  Loca+on	
  
•  First	
  loca+on	
  can	
  take	
  +me.	
  Use	
  cached	
  
   loca+on!	
  
    –  Loca+on	
  lastKnownLoca+on	
  =	
  
       loca+onManager.getLastKnownLoca+on(Loca+onManager
       .NETWORK_PROVIDER);	
  
Mock	
  Loca+on	
  Data	
  
•  If	
  you	
  don’t	
  have	
  Android	
  device,	
  you	
  can	
  use	
  
   emulator	
  for	
  loca+on	
  services	
  by	
  giving	
  mock	
  
   data	
  
•  Mock	
  data	
  works	
  only	
  with	
  GPS_PROVIDER	
  
•  Use	
  	
  
    –  Emulator	
  Control	
  View	
  from	
  Eclipse	
  
    –  DDMS	
  (Dalvik	
  Debug	
  Monitor	
  Server)	
  
    –  Geo	
  command	
  from	
  console	
  
Emulator	
  Control	
  View	
  
Geo	
  
•  Connect	
  to	
  emulator	
  from	
  console	
  
    –  telnet localhost <console-port>
•  Send	
  the	
  loca+on	
  data	
  
    –  geo fix -121 46
GOOGLE	
  MAPS	
  EXTERNAL	
  
DIRECTORY	
  
Google	
  Maps	
  
•  External	
  API	
  Add-­‐On	
  to	
  Android	
  SDK	
  
•  Install	
  Google	
  APIs	
  Add-­‐On	
  from	
  Android	
  SDK	
  
   and	
  AVD	
  Manager	
  (Google	
  APIs	
  by	
  Google)	
  
•  When	
  developing,	
  set	
  Google	
  API	
  Add-­‐On	
  as	
  
   target	
  
Google	
  APIs	
  as	
  Target	
  
Overview	
  
1.  Add	
  uses-­‐library	
  and	
  internet	
  permission	
  to	
  
    manifest	
  file	
  
2.  Use	
  the	
  Maps	
  API	
  
3.  Get	
  Maps	
  API	
  key	
  and	
  sign	
  your	
  app	
  
1.	
  Add	
  uses-­‐library	
  element	
  to	
  Manifest	
  file	
  

•  Because	
  we're	
  using	
  the	
  Google	
  Maps	
  library,	
  
   which	
  is	
  not	
  a	
  part	
  of	
  the	
  standard	
  Android	
  
   library,	
  we	
  need	
  to	
  declare	
  it	
  in	
  the	
  Android	
  
   Manifest	
  
    –  <uses-library
       android:name="com.google.android.maps" />
•  Internet	
  permissions	
  (downloadable	
  maps)	
  
    –  <uses-permission
         android:name="android.permission.INTERNET
         " />
    	
  
2.	
  Use	
  the	
  Maps	
  API:	
  MapView	
  
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/mainlayout"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

        <com.google.android.maps.MapView
            android:id="@+id/mapview"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:clickable="true"
            android:apiKey="Your Maps API Key"
        />

</RelativeLayout>
2.	
  Use	
  the	
  Maps	
  API:	
  Class	
  
3.	
  Get	
  Maps	
  API	
  key	
  and	
  Sign	
  Your	
  App	
  
•  Create	
  MD5	
  cer+ficate	
  fingerprint	
  either	
  in	
  
   release	
  or	
  in	
  debug	
  
•  Release	
  
    –  $ keytool -list -alias alias_name -keystore
       my-release-key.keystore
•  Debug	
  
    –  $ keytool -list -alias androiddebugkey -
       keystore <path_to_debug_keystore>.keystore -
       storepass android -keypass android
•  Path	
  to	
  debug	
  keystore	
  in	
  Windows	
  Vista	
  
    –  C:Users<user>.androiddebug.keystore
3.	
  Sign	
  with	
  the	
  Service	
  
•  hQp://code.google.com/android/maps-­‐api-­‐
   signup.html	
  
Showing	
  La+tude	
  and	
  Longitude	
  on	
  Map	
  

	
  mapView	
  =	
  (MapView)	
  findViewById(R.id.mapview);	
  
	
  mapController	
  =	
  mapView.getController();	
  
	
  	
  	
  
	
  int	
  lat	
  =	
  (int)	
  (loca+on.getLa+tude()	
  *	
  1E6);	
  
	
  int	
  lng	
  =	
  (int)	
  (loca+on.getLongitude()	
  *	
  1E6);	
  
	
  	
  
	
  GeoPoint	
  point	
  =	
  new	
  GeoPoint(lat,	
  lng);	
  
	
  mapController.animateTo(point);	
  
             	
   	
  	
  
DISPLAYING	
  GRAPHICS	
  ON	
  MAPS	
  
Custom	
  Markers	
  
•  Overlay	
  –	
  Individual	
  item	
  on	
  map	
  
•  Create	
  custom	
  class	
  that	
  inherites	
  
   ItemizedOverlay	
  class	
  
•  ItemizedOverlay	
  class	
  is	
  a	
  base	
  class	
  for	
  an	
  
   Overlay	
  which	
  consists	
  of	
  a	
  list	
  of	
  
   OverlayItems.	
  
ItemizedOverlay	
  




          MyOverlayItems	
  

ArrayList<OverlayItem> items

void addOverLay(OverlayItem i)
OverlayItem createItem(int i)
int size()
…
From	
  Ac+vity	
  
Android Location and Maps

More Related Content

What's hot

Android Telephony Manager and SMS
Android Telephony Manager and SMSAndroid Telephony Manager and SMS
Android Telephony Manager and SMSJussi Pohjolainen
 
Day: 1 Introduction to Mobile Application Development (in Android)
Day: 1 Introduction to Mobile Application Development (in Android)Day: 1 Introduction to Mobile Application Development (in Android)
Day: 1 Introduction to Mobile Application Development (in Android)Ahsanul Karim
 
Ii 1500-publishing your android application
Ii 1500-publishing your android applicationIi 1500-publishing your android application
Ii 1500-publishing your android applicationAdrian Mikeliunas
 
Android activities & views
Android activities & viewsAndroid activities & views
Android activities & viewsma-polimi
 
Android activity
Android activityAndroid activity
Android activityKrazy Koder
 
Android application structure
Android application structureAndroid application structure
Android application structureAlexey Ustenko
 
Introduction to Android development - Presentation
Introduction to Android development - PresentationIntroduction to Android development - Presentation
Introduction to Android development - PresentationAtul Panjwani
 
Android application development ppt
Android application development pptAndroid application development ppt
Android application development pptGautam Kumar
 
Introduction To Mobile Application Development
Introduction To Mobile Application DevelopmentIntroduction To Mobile Application Development
Introduction To Mobile Application DevelopmentSyed Absar
 
Maps in android
Maps in androidMaps in android
Maps in androidSumita Das
 
Introduction to android
Introduction to androidIntroduction to android
Introduction to androidzeelpatel0504
 
Introduction to Android
Introduction to Android Introduction to Android
Introduction to Android Ranjith Kumar
 
android activity
android activityandroid activity
android activityDeepa Rani
 
android architecture
android architectureandroid architecture
android architectureAashita Gupta
 

What's hot (20)

Android Telephony Manager and SMS
Android Telephony Manager and SMSAndroid Telephony Manager and SMS
Android Telephony Manager and SMS
 
Broadcast Receiver
Broadcast ReceiverBroadcast Receiver
Broadcast Receiver
 
Day: 1 Introduction to Mobile Application Development (in Android)
Day: 1 Introduction to Mobile Application Development (in Android)Day: 1 Introduction to Mobile Application Development (in Android)
Day: 1 Introduction to Mobile Application Development (in Android)
 
Ii 1500-publishing your android application
Ii 1500-publishing your android applicationIi 1500-publishing your android application
Ii 1500-publishing your android application
 
Android activities & views
Android activities & viewsAndroid activities & views
Android activities & views
 
Android activity
Android activityAndroid activity
Android activity
 
Android application structure
Android application structureAndroid application structure
Android application structure
 
Introduction to Android development - Presentation
Introduction to Android development - PresentationIntroduction to Android development - Presentation
Introduction to Android development - Presentation
 
Android application development ppt
Android application development pptAndroid application development ppt
Android application development ppt
 
Introduction To Mobile Application Development
Introduction To Mobile Application DevelopmentIntroduction To Mobile Application Development
Introduction To Mobile Application Development
 
Maps in android
Maps in androidMaps in android
Maps in android
 
Fragment
Fragment Fragment
Fragment
 
Introduction to android
Introduction to androidIntroduction to android
Introduction to android
 
Introduction to Android
Introduction to Android Introduction to Android
Introduction to Android
 
Android User Interface
Android User InterfaceAndroid User Interface
Android User Interface
 
Flutter workshop
Flutter workshopFlutter workshop
Flutter workshop
 
Broadcast receivers
Broadcast receiversBroadcast receivers
Broadcast receivers
 
Introduction to kotlin
Introduction to kotlinIntroduction to kotlin
Introduction to kotlin
 
android activity
android activityandroid activity
android activity
 
android architecture
android architectureandroid architecture
android architecture
 

Viewers also liked

Lecture Slides for Location based Services [Android]
Lecture Slides for Location based Services [Android]Lecture Slides for Location based Services [Android]
Lecture Slides for Location based Services [Android]Nehil Jain
 
Introduction to fragments in android
Introduction to fragments in androidIntroduction to fragments in android
Introduction to fragments in androidPrawesh Shrestha
 
Android Security, Signing and Publishing
Android Security, Signing and PublishingAndroid Security, Signing and Publishing
Android Security, Signing and PublishingJussi Pohjolainen
 
Android Http Connection and SAX Parsing
Android Http Connection and SAX ParsingAndroid Http Connection and SAX Parsing
Android Http Connection and SAX ParsingJussi Pohjolainen
 
Quick Intro to Android Development
Quick Intro to Android DevelopmentQuick Intro to Android Development
Quick Intro to Android DevelopmentJussi Pohjolainen
 
Google Maps API
Google Maps APIGoogle Maps API
Google Maps APIDave Ross
 
Android 2D Drawing and Animation Framework
Android 2D Drawing and Animation FrameworkAndroid 2D Drawing and Animation Framework
Android 2D Drawing and Animation FrameworkJussi Pohjolainen
 
Android Wi-Fi Manager and Bluetooth Connection
Android Wi-Fi Manager and Bluetooth ConnectionAndroid Wi-Fi Manager and Bluetooth Connection
Android Wi-Fi Manager and Bluetooth ConnectionJussi Pohjolainen
 
Android App Development - 06 Fragments
Android App Development - 06 FragmentsAndroid App Development - 06 Fragments
Android App Development - 06 FragmentsDiego Grancini
 
00 introduction-mobile-programming-course.ppt
00 introduction-mobile-programming-course.ppt00 introduction-mobile-programming-course.ppt
00 introduction-mobile-programming-course.pptJussi Pohjolainen
 

Viewers also liked (20)

Lecture Slides for Location based Services [Android]
Lecture Slides for Location based Services [Android]Lecture Slides for Location based Services [Android]
Lecture Slides for Location based Services [Android]
 
Introduction to fragments in android
Introduction to fragments in androidIntroduction to fragments in android
Introduction to fragments in android
 
Android Security, Signing and Publishing
Android Security, Signing and PublishingAndroid Security, Signing and Publishing
Android Security, Signing and Publishing
 
Android Essential Tools
Android Essential ToolsAndroid Essential Tools
Android Essential Tools
 
Android Http Connection and SAX Parsing
Android Http Connection and SAX ParsingAndroid Http Connection and SAX Parsing
Android Http Connection and SAX Parsing
 
Responsive Web Site Design
Responsive Web Site DesignResponsive Web Site Design
Responsive Web Site Design
 
Quick Intro to Android Development
Quick Intro to Android DevelopmentQuick Intro to Android Development
Quick Intro to Android Development
 
C# for Java Developers
C# for Java DevelopersC# for Java Developers
C# for Java Developers
 
Qt Translations
Qt TranslationsQt Translations
Qt Translations
 
Building Web Services
Building Web ServicesBuilding Web Services
Building Web Services
 
Google Maps API
Google Maps APIGoogle Maps API
Google Maps API
 
Android ui menu
Android ui menuAndroid ui menu
Android ui menu
 
Android 2D Drawing and Animation Framework
Android 2D Drawing and Animation FrameworkAndroid 2D Drawing and Animation Framework
Android 2D Drawing and Animation Framework
 
Android Wi-Fi Manager and Bluetooth Connection
Android Wi-Fi Manager and Bluetooth ConnectionAndroid Wi-Fi Manager and Bluetooth Connection
Android Wi-Fi Manager and Bluetooth Connection
 
Android App Development - 06 Fragments
Android App Development - 06 FragmentsAndroid App Development - 06 Fragments
Android App Development - 06 Fragments
 
00 introduction-mobile-programming-course.ppt
00 introduction-mobile-programming-course.ppt00 introduction-mobile-programming-course.ppt
00 introduction-mobile-programming-course.ppt
 
Android UI Development
Android UI DevelopmentAndroid UI Development
Android UI Development
 
Android Threading
Android ThreadingAndroid Threading
Android Threading
 
Android Data Persistence
Android Data PersistenceAndroid Data Persistence
Android Data Persistence
 
Android Sensors
Android SensorsAndroid Sensors
Android Sensors
 

Similar to Android Location and Maps

Android App Development 04 : Location API
Android App Development 04 : Location APIAndroid App Development 04 : Location API
Android App Development 04 : Location APIAnuchit Chalothorn
 
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 DevelopmentIJERD Editor
 
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.pdfAbdullahMunir32
 
Android location
Android locationAndroid location
Android locationKrazy Koder
 
Developing Windows Phone Apps with Maps and Location Services
Developing Windows Phone Apps with Maps and Location ServicesDeveloping Windows Phone Apps with Maps and Location Services
Developing Windows Phone Apps with Maps and Location ServicesNick Landry
 
gps_SEGMENTATION.pptx
gps_SEGMENTATION.pptxgps_SEGMENTATION.pptx
gps_SEGMENTATION.pptxmaniatindia
 
Android mobile application for gps
Android mobile application for gpsAndroid mobile application for gps
Android mobile application for gpsSutej Chakka
 
Matchinguu droidcon presentation
Matchinguu droidcon presentationMatchinguu droidcon presentation
Matchinguu droidcon presentationDroidcon Berlin
 
gps tracking techniques
gps tracking techniquesgps tracking techniques
gps tracking techniquespolsaurabh
 
Book Review Global Posiotining System
Book Review Global Posiotining SystemBook Review Global Posiotining System
Book Review Global Posiotining SystemAnonymous Singh
 
FIWARE: Managing Context Information at large scale
FIWARE: Managing Context Information at large scaleFIWARE: Managing Context Information at large scale
FIWARE: Managing Context Information at large scaleFermin Galan
 
Android App Development - 14 location, media and notifications
Android App Development - 14 location, media and notificationsAndroid App Development - 14 location, media and notifications
Android App Development - 14 location, media and notificationsDiego Grancini
 
Synapseindia android application development tutorial
Synapseindia android application development tutorialSynapseindia android application development tutorial
Synapseindia android application development tutorialSynapseindiappsdevelopment
 
Synapseindia android apps development tutorial
Synapseindia android apps  development tutorialSynapseindia android apps  development tutorial
Synapseindia android apps development tutorialSynapseindiappsdevelopment
 
orioncontextbroker-20180615
orioncontextbroker-20180615orioncontextbroker-20180615
orioncontextbroker-20180615Fermin Galan
 
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...Ibrahim Özgön
 
Android application for gps
Android application for gpsAndroid application for gps
Android application for gpsSutej Chakka
 
Leveraging the Globus Platform in Web Applications (CHPC 2019 - South Africa)
Leveraging the Globus Platform in Web Applications (CHPC 2019 - South Africa)Leveraging the Globus Platform in Web Applications (CHPC 2019 - South Africa)
Leveraging the Globus Platform in Web Applications (CHPC 2019 - South Africa)Globus
 

Similar to Android Location and Maps (20)

Android App Development 04 : Location API
Android App Development 04 : Location APIAndroid App Development 04 : Location API
Android App Development 04 : Location API
 
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
 
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 location
Android locationAndroid location
Android location
 
Developing Windows Phone Apps with Maps and Location Services
Developing Windows Phone Apps with Maps and Location ServicesDeveloping Windows Phone Apps with Maps and Location Services
Developing Windows Phone Apps with Maps and Location Services
 
Core Location in iOS
Core Location in iOSCore Location in iOS
Core Location in iOS
 
Android GNSS in Nutshell
Android GNSS in NutshellAndroid GNSS in Nutshell
Android GNSS in Nutshell
 
gps_SEGMENTATION.pptx
gps_SEGMENTATION.pptxgps_SEGMENTATION.pptx
gps_SEGMENTATION.pptx
 
Android mobile application for gps
Android mobile application for gpsAndroid mobile application for gps
Android mobile application for gps
 
Matchinguu droidcon presentation
Matchinguu droidcon presentationMatchinguu droidcon presentation
Matchinguu droidcon presentation
 
gps tracking techniques
gps tracking techniquesgps tracking techniques
gps tracking techniques
 
Book Review Global Posiotining System
Book Review Global Posiotining SystemBook Review Global Posiotining System
Book Review Global Posiotining System
 
FIWARE: Managing Context Information at large scale
FIWARE: Managing Context Information at large scaleFIWARE: Managing Context Information at large scale
FIWARE: Managing Context Information at large scale
 
Android App Development - 14 location, media and notifications
Android App Development - 14 location, media and notificationsAndroid App Development - 14 location, media and notifications
Android App Development - 14 location, media and notifications
 
Synapseindia android application development tutorial
Synapseindia android application development tutorialSynapseindia android application development tutorial
Synapseindia android application development tutorial
 
Synapseindia android apps development tutorial
Synapseindia android apps  development tutorialSynapseindia android apps  development tutorial
Synapseindia android apps development tutorial
 
orioncontextbroker-20180615
orioncontextbroker-20180615orioncontextbroker-20180615
orioncontextbroker-20180615
 
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...
 
Android application for gps
Android application for gpsAndroid application for gps
Android application for gps
 
Leveraging the Globus Platform in Web Applications (CHPC 2019 - South Africa)
Leveraging the Globus Platform in Web Applications (CHPC 2019 - South Africa)Leveraging the Globus Platform in Web Applications (CHPC 2019 - South Africa)
Leveraging the Globus Platform in Web Applications (CHPC 2019 - South Africa)
 

More from Jussi Pohjolainen

libGDX: Screens, Fonts and Preferences
libGDX: Screens, Fonts and PreferenceslibGDX: Screens, Fonts and Preferences
libGDX: Screens, Fonts and PreferencesJussi Pohjolainen
 
libGDX: User Input and Frame by Frame Animation
libGDX: User Input and Frame by Frame AnimationlibGDX: User Input and Frame by Frame Animation
libGDX: User Input and Frame by Frame AnimationJussi Pohjolainen
 
Intro to Building Android Games using libGDX
Intro to Building Android Games using libGDXIntro to Building Android Games using libGDX
Intro to Building Android Games using libGDXJussi Pohjolainen
 
Advanced JavaScript Development
Advanced JavaScript DevelopmentAdvanced JavaScript Development
Advanced JavaScript DevelopmentJussi Pohjolainen
 
libGDX: Simple Frame Animation
libGDX: Simple Frame AnimationlibGDX: Simple Frame Animation
libGDX: Simple Frame AnimationJussi Pohjolainen
 
libGDX: Simple Frame Animation
libGDX: Simple Frame AnimationlibGDX: Simple Frame Animation
libGDX: Simple Frame AnimationJussi Pohjolainen
 
Implementing a Simple Game using libGDX
Implementing a Simple Game using libGDXImplementing a Simple Game using libGDX
Implementing a Simple Game using libGDXJussi Pohjolainen
 
Building Android games using LibGDX
Building Android games using LibGDXBuilding Android games using LibGDX
Building Android games using LibGDXJussi Pohjolainen
 
Creating Asha Games: Game Pausing, Orientation, Sensors and Gestures
Creating Asha Games: Game Pausing, Orientation, Sensors and GesturesCreating Asha Games: Game Pausing, Orientation, Sensors and Gestures
Creating Asha Games: Game Pausing, Orientation, Sensors and GesturesJussi Pohjolainen
 
Creating Games for Asha - platform
Creating Games for Asha - platformCreating Games for Asha - platform
Creating Games for Asha - platformJussi Pohjolainen
 
Intro to Java ME and Asha Platform
Intro to Java ME and Asha PlatformIntro to Java ME and Asha Platform
Intro to Java ME and Asha PlatformJussi Pohjolainen
 

More from Jussi Pohjolainen (20)

Moved to Speakerdeck
Moved to SpeakerdeckMoved to Speakerdeck
Moved to Speakerdeck
 
Java Web Services
Java Web ServicesJava Web Services
Java Web Services
 
Box2D and libGDX
Box2D and libGDXBox2D and libGDX
Box2D and libGDX
 
libGDX: Screens, Fonts and Preferences
libGDX: Screens, Fonts and PreferenceslibGDX: Screens, Fonts and Preferences
libGDX: Screens, Fonts and Preferences
 
libGDX: Tiled Maps
libGDX: Tiled MapslibGDX: Tiled Maps
libGDX: Tiled Maps
 
libGDX: User Input and Frame by Frame Animation
libGDX: User Input and Frame by Frame AnimationlibGDX: User Input and Frame by Frame Animation
libGDX: User Input and Frame by Frame Animation
 
Intro to Building Android Games using libGDX
Intro to Building Android Games using libGDXIntro to Building Android Games using libGDX
Intro to Building Android Games using libGDX
 
Advanced JavaScript Development
Advanced JavaScript DevelopmentAdvanced JavaScript Development
Advanced JavaScript Development
 
Introduction to JavaScript
Introduction to JavaScriptIntroduction to JavaScript
Introduction to JavaScript
 
Introduction to AngularJS
Introduction to AngularJSIntroduction to AngularJS
Introduction to AngularJS
 
libGDX: Scene2D
libGDX: Scene2DlibGDX: Scene2D
libGDX: Scene2D
 
libGDX: Simple Frame Animation
libGDX: Simple Frame AnimationlibGDX: Simple Frame Animation
libGDX: Simple Frame Animation
 
libGDX: Simple Frame Animation
libGDX: Simple Frame AnimationlibGDX: Simple Frame Animation
libGDX: Simple Frame Animation
 
libGDX: User Input
libGDX: User InputlibGDX: User Input
libGDX: User Input
 
Implementing a Simple Game using libGDX
Implementing a Simple Game using libGDXImplementing a Simple Game using libGDX
Implementing a Simple Game using libGDX
 
Building Android games using LibGDX
Building Android games using LibGDXBuilding Android games using LibGDX
Building Android games using LibGDX
 
Creating Asha Games: Game Pausing, Orientation, Sensors and Gestures
Creating Asha Games: Game Pausing, Orientation, Sensors and GesturesCreating Asha Games: Game Pausing, Orientation, Sensors and Gestures
Creating Asha Games: Game Pausing, Orientation, Sensors and Gestures
 
Creating Games for Asha - platform
Creating Games for Asha - platformCreating Games for Asha - platform
Creating Games for Asha - platform
 
Intro to Asha UI
Intro to Asha UIIntro to Asha UI
Intro to Asha UI
 
Intro to Java ME and Asha Platform
Intro to Java ME and Asha PlatformIntro to Java ME and Asha Platform
Intro to Java ME and Asha Platform
 

Recently uploaded

Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 

Recently uploaded (20)

E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 

Android Location and Maps

  • 1. Android  Loca+on  and  Maps   Jussi  Pohjolainen  
  • 2. Loca+on  Services  and  Maps   •  Android  provides  loca+on  framework  that   your  app  can  use  to  determine     –  Device’s  loca+on   –  Listening  for  updates   •  Google  maps  external  library  available  for   displaying  and  managing  maps  
  • 4. Loca+on  Services   •  By  using  Loca+onManager  you  are  able  to   –  Query  for  the  list  of  Loca+onProviders  for  the  last   known  loca+on   –  Register  for  updates  of  the  user’s  current  loca+on   –  Register  for  given  Intent  to  be  fired  if  the  device   comes  within  given  proximity  of  given  lat/long  
  • 5. Obtaining  User  Loca+on   •  Loca+on  can  be  determined  via  GPS  and/or   cell  tower  +  Wi-­‐Fi  signals   •  GPS  is  accurate,  but  needs  outdoors,  fix  is   slower  and  it  uses  more  baQery.     •  To  request  loca+on,  you  use  Loca+onManager   -­‐  class    
  • 6. Reques+ng  Loca+on  Updates   Can  be  also   GPS_PROVIDER   Control   the   frequency   which   listener   receives   updates;   min  +me   and  min   distance  
  • 7. Reques+ng  User  Permissions   •  You  must  add  permissions  in  order  to  get  user   loca+on       •  ACCESS_COARSE_LOCATION   –  If  you  use  NETWORK_PROVIDER   •  ACCESS_FINE_LOCATION   –  If  you  use  GPS_PROVIDER  or  NETWORK_PROVIDER  
  • 8. Ge]ng  Last  Known  Loca+on   •  First  loca+on  can  take  +me.  Use  cached   loca+on!   –  Loca+on  lastKnownLoca+on  =   loca+onManager.getLastKnownLoca+on(Loca+onManager .NETWORK_PROVIDER);  
  • 9. Mock  Loca+on  Data   •  If  you  don’t  have  Android  device,  you  can  use   emulator  for  loca+on  services  by  giving  mock   data   •  Mock  data  works  only  with  GPS_PROVIDER   •  Use     –  Emulator  Control  View  from  Eclipse   –  DDMS  (Dalvik  Debug  Monitor  Server)   –  Geo  command  from  console  
  • 11. Geo   •  Connect  to  emulator  from  console   –  telnet localhost <console-port> •  Send  the  loca+on  data   –  geo fix -121 46
  • 12. GOOGLE  MAPS  EXTERNAL   DIRECTORY  
  • 13. Google  Maps   •  External  API  Add-­‐On  to  Android  SDK   •  Install  Google  APIs  Add-­‐On  from  Android  SDK   and  AVD  Manager  (Google  APIs  by  Google)   •  When  developing,  set  Google  API  Add-­‐On  as   target  
  • 14. Google  APIs  as  Target  
  • 15. Overview   1.  Add  uses-­‐library  and  internet  permission  to   manifest  file   2.  Use  the  Maps  API   3.  Get  Maps  API  key  and  sign  your  app  
  • 16. 1.  Add  uses-­‐library  element  to  Manifest  file   •  Because  we're  using  the  Google  Maps  library,   which  is  not  a  part  of  the  standard  Android   library,  we  need  to  declare  it  in  the  Android   Manifest   –  <uses-library android:name="com.google.android.maps" /> •  Internet  permissions  (downloadable  maps)   –  <uses-permission android:name="android.permission.INTERNET " />  
  • 17. 2.  Use  the  Maps  API:  MapView   <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"     android:id="@+id/mainlayout"     android:orientation="vertical"     android:layout_width="fill_parent"     android:layout_height="fill_parent" >     <com.google.android.maps.MapView         android:id="@+id/mapview"         android:layout_width="fill_parent"         android:layout_height="fill_parent"         android:clickable="true"         android:apiKey="Your Maps API Key"     /> </RelativeLayout>
  • 18. 2.  Use  the  Maps  API:  Class  
  • 19. 3.  Get  Maps  API  key  and  Sign  Your  App   •  Create  MD5  cer+ficate  fingerprint  either  in   release  or  in  debug   •  Release   –  $ keytool -list -alias alias_name -keystore my-release-key.keystore •  Debug   –  $ keytool -list -alias androiddebugkey - keystore <path_to_debug_keystore>.keystore - storepass android -keypass android •  Path  to  debug  keystore  in  Windows  Vista   –  C:Users<user>.androiddebug.keystore
  • 20. 3.  Sign  with  the  Service   •  hQp://code.google.com/android/maps-­‐api-­‐ signup.html  
  • 21. Showing  La+tude  and  Longitude  on  Map    mapView  =  (MapView)  findViewById(R.id.mapview);    mapController  =  mapView.getController();          int  lat  =  (int)  (loca+on.getLa+tude()  *  1E6);    int  lng  =  (int)  (loca+on.getLongitude()  *  1E6);        GeoPoint  point  =  new  GeoPoint(lat,  lng);    mapController.animateTo(point);        
  • 23. Custom  Markers   •  Overlay  –  Individual  item  on  map   •  Create  custom  class  that  inherites   ItemizedOverlay  class   •  ItemizedOverlay  class  is  a  base  class  for  an   Overlay  which  consists  of  a  list  of   OverlayItems.  
  • 24. ItemizedOverlay   MyOverlayItems   ArrayList<OverlayItem> items void addOverLay(OverlayItem i) OverlayItem createItem(int i) int size() …
  • 25.