SlideShare a Scribd company logo
1 of 22
Download to read offline
Android Application Development
      Google Maps API V2 Part 1




                                     Ahsanul Karim
                             karim.ahsanul@gmail.com
                    http://droidtraining.wordpress.com
Google Maps API V2
                                                  Steps
● Download and configure the Google Play services
   SDK. The Google Maps Android API is distributed as
   part of this SDK.
● Obtain an API key. To do this, you will need to register
   a project in the Google APIs Console, and get a
   signing certificate for your app.
● Specify settings in the Application Manifest.
● Add a map to a new or existing Android project.
● Publish your application
Google Maps API V2
                                        Google Play Services [1]
First need to install the Google Play services SDK using SDK Manager

1. Launch the SDK Manager

2. Select Extras > Google Play services, and install it
Google Maps API V2                   Google Play Services [2]
The Google Play services SDK is saved in your Android SDK environment
at <android-sdk-folder>/extras/google/google_play_services/
Google Maps API V2                         Google Play Services [3]
3. import the library project into your workspace. Click File > Import,
select Android > Existing Android Code into Workspace, and browse to the
copy of the library project [libproject] to import it.
Google Maps API V2           Google Play Services [4]
Select and Import project.
Google Maps API V2                   Google Play Services [5]
Project is imported as Library as seen in Project Properties
Google Maps API V2                  Google Play Services [6]
4. Create a new project to integrate Maps
Google Maps API V2                      Google Play Services [7]
5. Go to project properties of Google maps V2 Demo and reference
the google-play-services_lib project.
Google Maps API V2                         Android Manifest [1]
Now we are going to prepare the AndroidManifest.xml file of
Google Maps V2 Demo project:

1. In AndroidManifest.xml, add the following element as a child of
the <application> element, by inserting it just before the closing
tag</application>

                                                  Specifying Map
                                                  API_KEY in metadata
                                                  makes it available to
                                                  any MapFragment
                                                  used in the project.
                                                  We'll create our own
                                                  API_KEY a bit later.
Google Maps API V2                      Android Manifest [2]
2. Add the following elements to your manifest. Replace com.
smartapps.googlemapsv2.demo with the package name of your
application.




3. Save AndroidManifest.xml and rebuild your application.
Google Maps API V2                          Android Manifest [3]
4. Add following permissions in AndroidManifest.xml




5. Because version 2 of the Google Maps Android API requires OpenGL
ES version 2, you must add a <uses-feature> element as a child of the
<manifest> element in AndroidManifest.xml
Google Maps API V2
                                    Obtaining Maps API KEY [1]
1. To access the Google Maps servers with the Maps API, we have to
add a Maps API key to our application.

2. The key is free, we can use it with any of our applications that call
the Maps API, and it supports an unlimited number of users.

3. We'll obtain a Maps API key from the Google APIs Console by
providing your application's signing certificate and its package name.
So there will be separate Maps API key for debug keystore and release
keystore.

4. Once we have the key, we add it to our application by adding an
element to AndroidManifest.xml.

5. Recommended practice is to sign each of our applications with a
different certificate and get a different key for each one.
Google Maps API V2
                               Obtaining Maps API KEY [2]
Steps for obtaining an API key :
1. Retrieve information about the application's certificate.
2. Register a project in the Google APIs Console and add the
Maps API as a service for the project.
3. Once we have a project set up, we can request one or more
keys.
4. Finally, we can add the key to our application and begin
development.


These steps will be described in next slides...
Google Maps API V2
                                 Obtaining Maps API KEY [3]
Step 1: Certificate Info & SHA1 Fingerprint
a. Locate Keystore: Go to Preferences-> Android-> Build




By default: Path to debug.keystore
OS X and Linux: ~/.android/
Windows Vista and Windows 7: C:Usersyour_user_name.android
Google Maps API V2
                                       Obtaining Maps API KEY [4]
     Step 1: Certificate Info & SHA1 Fingerprint
     b. Get SHA1 Fingerprint:
Open Terminal/Cmd Prompt and write following command to get SHA1 Fingerprint:

In   OSX/Linux:

keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -
storepass android -keypass android

In   Windows Vista/Windows 7:

keytool -list -v -keystore "C:Usersyour_user_name.androiddebug.keystore" -
alias androiddebugkey -storepass android -keypass android


     1. Be careful about the path of debug.keystore in command.
     2. In windows, if environment variable is not set, you may need to
     write the command after going to java/bin folder with keytool.exe.
Google Maps API V2
                                 Obtaining Maps API KEY [4]
Step 1: Certificate Info & SHA1 Fingerprint
b. Get SHA1 Fingerprint: Output in Terminal
Google Maps API V2
                                       Obtaining Maps API KEY [5]
Step 2: Creating an API Project
1. In browser, navigate to Google API Concole [https://code.google.
com/apis/console/] and Login with Gmail ID.

2. Create New Project and Enable Google Maps Android API V2 Service from
services list.
Google Maps API V2
                                           Obtaining Maps API KEY [6]
 Step 2: Request for API Key
 It's possible to register more than one key per project.
 To get the key:

 1. In the left navigation bar, click API Access.

 2. In the resulting page, click Create New Android Key....

 3. In the resulting dialog, enter the SHA-1 fingerprint, then a semicolon, then our
 application's package name. For example: in our case


1E:36:29:E1:F4:DD:FB:5C:AF:8B:99:BA:FC:E7:A5:03:51:14:19:B65;com.smartapps.
googlemapsv2.demo

 4. API Console responds with a 40-character key:
AIzaSyCQL_pZ_EA85MzBEeNDxNCtlQnt3-V_OGU
Google Maps API V2
                              Obtaining Maps API KEY [6]
Step 2: Request for API Key
Google Maps API V2
                                             Add a Map [1]
Step 1: Add a MapFragment to activity_main.xml




Step 2: MainActivity.java
Google Maps API V2
                                                         Add a Map [2]
Step 3: Build and Run
1. Now we should see the map in a real device
2. Map cannot be shown in emulator as long as Google Play Store application is
not installed in emulator

More Related Content

Viewers also liked

Creating the first app with android studio
Creating the first app with android studioCreating the first app with android studio
Creating the first app with android studioParinita03
 
Android User Interface: Basic Form Widgets
Android User Interface: Basic Form WidgetsAndroid User Interface: Basic Form Widgets
Android User Interface: Basic Form WidgetsAhsanul Karim
 
Day 8: Dealing with Lists and ListViews
Day 8: Dealing with Lists and ListViewsDay 8: Dealing with Lists and ListViews
Day 8: Dealing with Lists and ListViewsAhsanul Karim
 
Android User Interface Tutorial: DatePicker, TimePicker & Spinner
Android User Interface Tutorial: DatePicker, TimePicker & SpinnerAndroid User Interface Tutorial: DatePicker, TimePicker & Spinner
Android User Interface Tutorial: DatePicker, TimePicker & SpinnerAhsanul Karim
 
Action Bar Sherlock tutorial
Action Bar Sherlock tutorialAction Bar Sherlock tutorial
Action Bar Sherlock tutorialAhsanul Karim
 
Day 4: Android: UI Widgets
Day 4: Android: UI WidgetsDay 4: Android: UI Widgets
Day 4: Android: UI WidgetsAhsanul Karim
 
Android MapView and MapActivity
Android MapView and MapActivityAndroid MapView and MapActivity
Android MapView and MapActivityAhsanul Karim
 
Sensors in Android (old)
Sensors in Android (old)Sensors in Android (old)
Sensors in Android (old)Ahsanul Karim
 
Lecture 3 getting active through activities
Lecture 3 getting active through activities Lecture 3 getting active through activities
Lecture 3 getting active through activities Ahsanul Karim
 
Day1 before getting_started
Day1 before getting_startedDay1 before getting_started
Day1 before getting_startedAhsanul Karim
 
Multiple Activity and Navigation Primer
Multiple Activity and Navigation PrimerMultiple Activity and Navigation Primer
Multiple Activity and Navigation PrimerAhsanul Karim
 
Android Workshop Day 1 Part 2
Android Workshop Day 1 Part 2Android Workshop Day 1 Part 2
Android Workshop Day 1 Part 2Ahsanul Karim
 

Viewers also liked (18)

Creating the first app with android studio
Creating the first app with android studioCreating the first app with android studio
Creating the first app with android studio
 
Android User Interface: Basic Form Widgets
Android User Interface: Basic Form WidgetsAndroid User Interface: Basic Form Widgets
Android User Interface: Basic Form Widgets
 
Day 8: Dealing with Lists and ListViews
Day 8: Dealing with Lists and ListViewsDay 8: Dealing with Lists and ListViews
Day 8: Dealing with Lists and ListViews
 
List Views
List ViewsList Views
List Views
 
Android 1.8 sensor
Android 1.8 sensorAndroid 1.8 sensor
Android 1.8 sensor
 
Android User Interface Tutorial: DatePicker, TimePicker & Spinner
Android User Interface Tutorial: DatePicker, TimePicker & SpinnerAndroid User Interface Tutorial: DatePicker, TimePicker & Spinner
Android User Interface Tutorial: DatePicker, TimePicker & Spinner
 
Action Bar Sherlock tutorial
Action Bar Sherlock tutorialAction Bar Sherlock tutorial
Action Bar Sherlock tutorial
 
Day 4: Android: UI Widgets
Day 4: Android: UI WidgetsDay 4: Android: UI Widgets
Day 4: Android: UI Widgets
 
Android MapView and MapActivity
Android MapView and MapActivityAndroid MapView and MapActivity
Android MapView and MapActivity
 
Android Services
Android ServicesAndroid Services
Android Services
 
Sensors in Android (old)
Sensors in Android (old)Sensors in Android (old)
Sensors in Android (old)
 
Training android
Training androidTraining android
Training android
 
Lecture 3 getting active through activities
Lecture 3 getting active through activities Lecture 3 getting active through activities
Lecture 3 getting active through activities
 
Day1 before getting_started
Day1 before getting_startedDay1 before getting_started
Day1 before getting_started
 
Mcq peresentation
Mcq  peresentationMcq  peresentation
Mcq peresentation
 
GCM for Android
GCM for AndroidGCM for Android
GCM for Android
 
Multiple Activity and Navigation Primer
Multiple Activity and Navigation PrimerMultiple Activity and Navigation Primer
Multiple Activity and Navigation Primer
 
Android Workshop Day 1 Part 2
Android Workshop Day 1 Part 2Android Workshop Day 1 Part 2
Android Workshop Day 1 Part 2
 

More from Ahsanul Karim

Lecture 5: Storage: Saving Data Database, Files & Preferences
Lecture 5: Storage: Saving Data Database, Files & PreferencesLecture 5: Storage: Saving Data Database, Files & Preferences
Lecture 5: Storage: Saving Data Database, Files & PreferencesAhsanul Karim
 
Lecture 2(b) Android Internals A Quick Overview
Lecture 2(b) Android Internals A Quick OverviewLecture 2(b) Android Internals A Quick Overview
Lecture 2(b) Android Internals A Quick OverviewAhsanul Karim
 
Lecture 1 Session 1 Before Getting Started
Lecture 1 Session 1 Before Getting StartedLecture 1 Session 1 Before Getting Started
Lecture 1 Session 1 Before Getting StartedAhsanul Karim
 
লেকচার ১ (ক)- শুরুর আগে:
লেকচার ১ (ক)- শুরুর আগে:লেকচার ১ (ক)- শুরুর আগে:
লেকচার ১ (ক)- শুরুর আগে:Ahsanul Karim
 
Day 15: Content Provider: Using Contacts API
Day 15: Content Provider: Using Contacts APIDay 15: Content Provider: Using Contacts API
Day 15: Content Provider: Using Contacts APIAhsanul Karim
 
Day 15: Working in Background
Day 15: Working in BackgroundDay 15: Working in Background
Day 15: Working in BackgroundAhsanul Karim
 
Day 9: Make Your App Location Aware using Location API
Day 9: Make Your App Location Aware using Location APIDay 9: Make Your App Location Aware using Location API
Day 9: Make Your App Location Aware using Location APIAhsanul Karim
 
Day 8: Dealing with Lists and ListViews
Day 8: Dealing with Lists and ListViewsDay 8: Dealing with Lists and ListViews
Day 8: Dealing with Lists and ListViewsAhsanul Karim
 
Day 6: Android BroadcastReceiver Component
Day 6: Android BroadcastReceiver ComponentDay 6: Android BroadcastReceiver Component
Day 6: Android BroadcastReceiver ComponentAhsanul Karim
 
Day 5: Android User Interface [View Widgets]
Day 5: Android User Interface [View Widgets]Day 5: Android User Interface [View Widgets]
Day 5: Android User Interface [View Widgets]Ahsanul Karim
 
Day 4: Activity lifecycle
Day 4: Activity lifecycleDay 4: Activity lifecycle
Day 4: Activity lifecycleAhsanul Karim
 
Day 1 Android: Before Getting Started
Day 1 Android: Before Getting StartedDay 1 Android: Before Getting Started
Day 1 Android: Before Getting StartedAhsanul Karim
 
Mobile Banking in Bangladesh: An Incomplete Study
Mobile Banking in Bangladesh: An Incomplete StudyMobile Banking in Bangladesh: An Incomplete Study
Mobile Banking in Bangladesh: An Incomplete StudyAhsanul Karim
 
Ui layout (incomplete)
Ui layout (incomplete)Ui layout (incomplete)
Ui layout (incomplete)Ahsanul Karim
 
Android before getting started
Android before getting startedAndroid before getting started
Android before getting startedAhsanul Karim
 
Introduction to Android Development: Before Getting Started
Introduction to Android Development: Before Getting StartedIntroduction to Android Development: Before Getting Started
Introduction to Android Development: Before Getting StartedAhsanul Karim
 

More from Ahsanul Karim (17)

Lecture 5: Storage: Saving Data Database, Files & Preferences
Lecture 5: Storage: Saving Data Database, Files & PreferencesLecture 5: Storage: Saving Data Database, Files & Preferences
Lecture 5: Storage: Saving Data Database, Files & Preferences
 
Lecture 2(b) Android Internals A Quick Overview
Lecture 2(b) Android Internals A Quick OverviewLecture 2(b) Android Internals A Quick Overview
Lecture 2(b) Android Internals A Quick Overview
 
Lecture 1 Session 1 Before Getting Started
Lecture 1 Session 1 Before Getting StartedLecture 1 Session 1 Before Getting Started
Lecture 1 Session 1 Before Getting Started
 
লেকচার ১ (ক)- শুরুর আগে:
লেকচার ১ (ক)- শুরুর আগে:লেকচার ১ (ক)- শুরুর আগে:
লেকচার ১ (ক)- শুরুর আগে:
 
Day 15: Content Provider: Using Contacts API
Day 15: Content Provider: Using Contacts APIDay 15: Content Provider: Using Contacts API
Day 15: Content Provider: Using Contacts API
 
Day 15: Working in Background
Day 15: Working in BackgroundDay 15: Working in Background
Day 15: Working in Background
 
Day 9: Make Your App Location Aware using Location API
Day 9: Make Your App Location Aware using Location APIDay 9: Make Your App Location Aware using Location API
Day 9: Make Your App Location Aware using Location API
 
Day 8: Dealing with Lists and ListViews
Day 8: Dealing with Lists and ListViewsDay 8: Dealing with Lists and ListViews
Day 8: Dealing with Lists and ListViews
 
Day 6: Android BroadcastReceiver Component
Day 6: Android BroadcastReceiver ComponentDay 6: Android BroadcastReceiver Component
Day 6: Android BroadcastReceiver Component
 
Day 5: Android User Interface [View Widgets]
Day 5: Android User Interface [View Widgets]Day 5: Android User Interface [View Widgets]
Day 5: Android User Interface [View Widgets]
 
Day 4: Activity lifecycle
Day 4: Activity lifecycleDay 4: Activity lifecycle
Day 4: Activity lifecycle
 
Day 1 Android: Before Getting Started
Day 1 Android: Before Getting StartedDay 1 Android: Before Getting Started
Day 1 Android: Before Getting Started
 
Mobile Banking in Bangladesh: An Incomplete Study
Mobile Banking in Bangladesh: An Incomplete StudyMobile Banking in Bangladesh: An Incomplete Study
Mobile Banking in Bangladesh: An Incomplete Study
 
Ui layout (incomplete)
Ui layout (incomplete)Ui layout (incomplete)
Ui layout (incomplete)
 
AndroidManifest
AndroidManifestAndroidManifest
AndroidManifest
 
Android before getting started
Android before getting startedAndroid before getting started
Android before getting started
 
Introduction to Android Development: Before Getting Started
Introduction to Android Development: Before Getting StartedIntroduction to Android Development: Before Getting Started
Introduction to Android Development: Before Getting Started
 

Recently uploaded

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
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...Neo4j
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfhans926745
 
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
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
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.pdfUK Journal
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
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.pdfsudhanshuwaghmare1
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
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 RobisonAnna Loughnan Colquhoun
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 

Recently uploaded (20)

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
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...
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
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
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
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
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
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
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
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
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 

Day 13: Google Maps Android API v2: Part 1

  • 1. Android Application Development Google Maps API V2 Part 1 Ahsanul Karim karim.ahsanul@gmail.com http://droidtraining.wordpress.com
  • 2. Google Maps API V2 Steps ● Download and configure the Google Play services SDK. The Google Maps Android API is distributed as part of this SDK. ● Obtain an API key. To do this, you will need to register a project in the Google APIs Console, and get a signing certificate for your app. ● Specify settings in the Application Manifest. ● Add a map to a new or existing Android project. ● Publish your application
  • 3. Google Maps API V2 Google Play Services [1] First need to install the Google Play services SDK using SDK Manager 1. Launch the SDK Manager 2. Select Extras > Google Play services, and install it
  • 4. Google Maps API V2 Google Play Services [2] The Google Play services SDK is saved in your Android SDK environment at <android-sdk-folder>/extras/google/google_play_services/
  • 5. Google Maps API V2 Google Play Services [3] 3. import the library project into your workspace. Click File > Import, select Android > Existing Android Code into Workspace, and browse to the copy of the library project [libproject] to import it.
  • 6. Google Maps API V2 Google Play Services [4] Select and Import project.
  • 7. Google Maps API V2 Google Play Services [5] Project is imported as Library as seen in Project Properties
  • 8. Google Maps API V2 Google Play Services [6] 4. Create a new project to integrate Maps
  • 9. Google Maps API V2 Google Play Services [7] 5. Go to project properties of Google maps V2 Demo and reference the google-play-services_lib project.
  • 10. Google Maps API V2 Android Manifest [1] Now we are going to prepare the AndroidManifest.xml file of Google Maps V2 Demo project: 1. In AndroidManifest.xml, add the following element as a child of the <application> element, by inserting it just before the closing tag</application> Specifying Map API_KEY in metadata makes it available to any MapFragment used in the project. We'll create our own API_KEY a bit later.
  • 11. Google Maps API V2 Android Manifest [2] 2. Add the following elements to your manifest. Replace com. smartapps.googlemapsv2.demo with the package name of your application. 3. Save AndroidManifest.xml and rebuild your application.
  • 12. Google Maps API V2 Android Manifest [3] 4. Add following permissions in AndroidManifest.xml 5. Because version 2 of the Google Maps Android API requires OpenGL ES version 2, you must add a <uses-feature> element as a child of the <manifest> element in AndroidManifest.xml
  • 13. Google Maps API V2 Obtaining Maps API KEY [1] 1. To access the Google Maps servers with the Maps API, we have to add a Maps API key to our application. 2. The key is free, we can use it with any of our applications that call the Maps API, and it supports an unlimited number of users. 3. We'll obtain a Maps API key from the Google APIs Console by providing your application's signing certificate and its package name. So there will be separate Maps API key for debug keystore and release keystore. 4. Once we have the key, we add it to our application by adding an element to AndroidManifest.xml. 5. Recommended practice is to sign each of our applications with a different certificate and get a different key for each one.
  • 14. Google Maps API V2 Obtaining Maps API KEY [2] Steps for obtaining an API key : 1. Retrieve information about the application's certificate. 2. Register a project in the Google APIs Console and add the Maps API as a service for the project. 3. Once we have a project set up, we can request one or more keys. 4. Finally, we can add the key to our application and begin development. These steps will be described in next slides...
  • 15. Google Maps API V2 Obtaining Maps API KEY [3] Step 1: Certificate Info & SHA1 Fingerprint a. Locate Keystore: Go to Preferences-> Android-> Build By default: Path to debug.keystore OS X and Linux: ~/.android/ Windows Vista and Windows 7: C:Usersyour_user_name.android
  • 16. Google Maps API V2 Obtaining Maps API KEY [4] Step 1: Certificate Info & SHA1 Fingerprint b. Get SHA1 Fingerprint: Open Terminal/Cmd Prompt and write following command to get SHA1 Fingerprint: In OSX/Linux: keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey - storepass android -keypass android In Windows Vista/Windows 7: keytool -list -v -keystore "C:Usersyour_user_name.androiddebug.keystore" - alias androiddebugkey -storepass android -keypass android 1. Be careful about the path of debug.keystore in command. 2. In windows, if environment variable is not set, you may need to write the command after going to java/bin folder with keytool.exe.
  • 17. Google Maps API V2 Obtaining Maps API KEY [4] Step 1: Certificate Info & SHA1 Fingerprint b. Get SHA1 Fingerprint: Output in Terminal
  • 18. Google Maps API V2 Obtaining Maps API KEY [5] Step 2: Creating an API Project 1. In browser, navigate to Google API Concole [https://code.google. com/apis/console/] and Login with Gmail ID. 2. Create New Project and Enable Google Maps Android API V2 Service from services list.
  • 19. Google Maps API V2 Obtaining Maps API KEY [6] Step 2: Request for API Key It's possible to register more than one key per project. To get the key: 1. In the left navigation bar, click API Access. 2. In the resulting page, click Create New Android Key.... 3. In the resulting dialog, enter the SHA-1 fingerprint, then a semicolon, then our application's package name. For example: in our case 1E:36:29:E1:F4:DD:FB:5C:AF:8B:99:BA:FC:E7:A5:03:51:14:19:B65;com.smartapps. googlemapsv2.demo 4. API Console responds with a 40-character key: AIzaSyCQL_pZ_EA85MzBEeNDxNCtlQnt3-V_OGU
  • 20. Google Maps API V2 Obtaining Maps API KEY [6] Step 2: Request for API Key
  • 21. Google Maps API V2 Add a Map [1] Step 1: Add a MapFragment to activity_main.xml Step 2: MainActivity.java
  • 22. Google Maps API V2 Add a Map [2] Step 3: Build and Run 1. Now we should see the map in a real device 2. Map cannot be shown in emulator as long as Google Play Store application is not installed in emulator