Online Tutorials & Training Materials |
Register Login

Location Manager GPS Application in Android

|| 0

Location Manager GPS Application in Android

How to Create Simple Google Map Application

To display google map you need to connect your android application to the google map server. For getting a response from your google map server you need to put some API key in your android application. You will get the API key from google developer console by providing your SHA 1 certificate fingerprint and your application package. So here in this episode, I am going to show you how to create a simple google map android application.

The google map API is the part of google play service. So first, you need to make sure that you installed the google play service in your android SDK.

Please follow the steps below for creating simple Google Map Application:

So open Android Studio and start the SDK manager.

Open up the stand-alone SDK manager.

Now inside the SDK manager search for an “extra” folder, click on the “Extras” folder and you need to find out the Google Play Service. Here I already installed the Google Play Services, if it is not installed you need to install Google Play Services first.

Now start the new Android Studio Project.

And I name it as GoogleMapDemoApp.

And click next. There is IceCreamSandwich and there is no need to change anything here therefore click next.

Now from this window, you need to select the google map activity, instead of a blank activity, select the google maps activity and click next.

Now here is the activity name, layout name and title and finally click finish.

Now the project created.

Now we need know how to get the API key from google developer console. To get the API key from google developer console you need to submit some credentials. So the android studio will automatically create the needed credential. The credential contains a SHA 1 certificate, fingerprint and package name.

This line contains my SHA 1 certificate fingerprint and package name and I have hid this area for security reasons. And after getting the API key from the android developer console you need to write the key here. ? Here the URLs are available, you can use this URL to directly open the google developer console and this URL contains the need credentials. Also you can use this information to reuse an existing key. So here I am going to add information manually google developer console. Now we have the need credentials inside google developer console.

For that open up google browser, search for google developer console, and open the google developer console website.

From these options, create a new project.

Here you need to provide a project name. Here I name it as GoogleMapDemoAppPrjct and click create option.

Now you can see the project creation status.

Now the project is created and you can see the current project name from here. Now the current project is GoogleMapDemoAppPrjct.

Now we need to submit the credentials into the google developer console. First, open this option APIs &auth and select credentials. Here we need to how to get an API key for an android application.

There are two options- Create new Clint ID and Create new Key.

We need an API key for Android application. So select this option- Create new Key. And we need the API key for the android application so select the Android Key.

And here you need to need to provide the needed credentials. The credentials contain both an SHA certification fingerprint and the package name followed by a semicolon. Here is an example of a credential. This one represents an SHA certification fingerprint put a semicolon and after that and you need to provide the package name. You will get all this information from Android studio. So now, I am going to copy the details from Android studio. 

So in Android studio, here will get the credential from this line. You need to copy this entire line and submit in the google developer console. So now, I am going to copy this line. now I submit the credentials in google developer console.

Now I need to click the create button and API key will be generated, and also there are the android application details that contain the certificate fingerprint and the application package name, here is application activation date, and here it is activated by email address.

So now, you need to copy this API key and put it in your android application. before you leave the android developer console, you need to enable the API for the project.

So now, the current project is GoogleMapDemoAppPrjct. So you need to select the APIs option and the Google Map Android API.

And you need to enable the API for the current project and click this enable API button.

Now when the google map API enables the project then you can copy the API key from credentials and put it in your Android Application.

Now here is an example of API key. This is not the complete API key; I have removed some more portion of this API key because of some security reasons. And every API key is start with the word AIzaSyD.

Now we will successfully add the API key here. Now we need to search some permission to manifest.aml file to display google map. You need to get the internet permission and need to get some user current location permission etc.

So we can check it out in the android manifest.xml file.

Here the android studio automatically adds the needed permission because when we create this project we select the google map activity that’s why Android studio added all these permissions.

These permissions are needed for getting the internet get the current internet network state and get the current user location from the network provider and from GPS.


There is some Metadata available, these permissions are getting the user current location and there some Metadata.

The first Metadata is for GPS and second Metadata is for supporting the google map API key. And here this one is the google play service version. There is no need to add all these information; android studio will add all this information for you.

Now we will learn how to take it to the main activity. Java file. All these code sections are auto generated.

In the method there is a Markers added and here is a title for the marker.

I change the title into “This is my First Marker”. ? Now we need to get some coordinates of some places from google map. Here we need to put the latitude and longitude of some places.

Now search for google map and open google map and search for some places.

And I need to get the coordinates of this place. For that click this place and choose this option “what is here” and this is the coordinates of that particular place.

So I copy this coordinates.

Now open android studio and instead of these (0,0) we need to put that coordinates.

Now we successfully add a new marker into the google map. Now we can see what it does on the aerial device. It is not possible to run this application on a virtual device because to display google map you need the google play service. So you need to run this application on the aerial device.

Therefore, install the application on the aerial device and here is the application and open that application.

Now you need to display the google map and add the marker on this application.

Now you can find the title on the marker by just clicking the marker and this the title.

Related Articles