<p>This guide is a quick start to adding a map to an Android app. We are using Android Studio as a development environment.</p>
<p>Get the full code from <strong><a href="https://github.com/arunk7839/GoogleMapExample">Github</a></strong></p>
<p><span style="color: #000080;"><strong>Step 1. Create a Google Maps project</strong></span></p>
<p>Follow these steps to create a new app project including a map activity:</p>
<ol>
<li>Start Android Studio.</li>
<li>Create a new project.</li>
<li>Enter your app name, company domain, and project location, as prompted. Then click <span style="color: #008000;"><strong>Next</strong></span>.</li>
<li>Select the form factors you need for your app or just select <span style="color: #008000;"><strong>Phone and Tablet</strong></span>. Then click <span style="color: #008000;"><strong>Next</strong></span>.</li>
<li>Select <span style="color: #008000;"><strong>Google Maps Activity</strong></span> in the &#8216;Add an activity to Mobile&#8217; dialog. Then click <span style="color: #008000;"><strong>Next</strong></span>.</li>
<li>Enter the activity name, layout name and title. Then click <span style="color: #008000;"><strong>Finish</strong></span>.</li>
</ol>
<p> ;</p>
<p><span style="color: #000080;"><strong>Step 2.Get a Google Maps API key</strong></span></p>
<p style="text-align: left;"> For getting the map api key go to <strong><a href="https://console.developers.google.com/?_ga=2.188092840.1254419158.1526730950-593994706.1525417017">Google API Console.</a></strong> or watch the video how to create the Map API key:</p>
<p> ;</p>
<p><amp-youtube layout="responsive" width="1200" height="900" data-videoid="FpHbIPVEC88" title="Android GoogleMap API Key Creation"><a placeholder href="https://www.youtube.com/watch?v=FpHbIPVEC88"><img src="https://i.ytimg.com/vi/FpHbIPVEC88/hqdefault.jpg" layout="fill" object-fit="cover" alt="Android GoogleMap API Key Creation"></a></amp-youtube></p>
<h2 id="step_5_hello_map_take_a_look_at_the_code"></h2>
<p><span style="color: #000080;"><strong>Step 3.Hello Map! Take a look at the code</strong></span></p>
<p id="the_xml_layout_file"><span style="color: #0000ff;"><strong>The app build.gradle file</strong></span></p>
<pre><code>dependencies {
 implementation fileTree(dir: 'libs', include: ['*.jar'])
 implementation 'com.android.support:appcompat-v7:27.1.1'
 <strong><span style="color: #008000;">// for google map</span></strong>
 implementation 'com.google.android.gms:play-services-maps:15.0.1'
}</code></pre>
<p><span style="color: #0000ff;"><strong>The Manifest file</strong></span></p>
<!-- WP QUADS Content Ad Plugin v. 2.0.98.1 -->
<div class="quads-location quads-ad2" id="quads-ad2" style="float:none;margin:0px;">

</div>

<pre><code><;?xml version="1.0" encoding="utf-8"?>;
<;manifest xmlns:android="http://schemas.android.com/apk/res/android"
 package="c1c.googlemapexample">;

 <strong><span style="color: #008000;"><;!--
 The ACCESS_COARSE/FINE_LOCATION permissions are not required to use
 Google Maps Android API v2, but you must specify either coarse or fine
 location permissions for the 'MyLocation' functionality. 
 -->;</span></strong>
 <;uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />;

 <;application
 android:allowBackup="true"
 android:icon="@mipmap/ic_launcher"
 android:label="@string/app_name"
 android:roundIcon="@mipmap/ic_launcher_round"
 android:supportsRtl="true"
 android:theme="@style/AppTheme">;
 <;activity android:name=".MapsActivity">;
 <;intent-filter>;
 <;action android:name="android.intent.action.MAIN" />;

 <;category android:name="android.intent.category.LAUNCHER" />;
 <;/intent-filter>;
 <;/activity>;
 <strong><span style="color: #008000;"> <;!--
 Note that the API key is linked to the encryption key used to sign the APK.
 You need a different API key for each encryption key, including the release key that is used to
 sign the APK for publishing.
 You can define the keys for the debug and release targets in src/debug/ and src/release/. 
 -->;</span></strong>
 <;meta-data
 android:name="com.google.android.geo.API_KEY"
 android:value="<span style="color: #ff0000;"><strong>ADD_YOUR_GOOGLE_MAP_API_KEY</strong></span>" />;


 <;/application>;

<;/manifest>;</code></pre>
<p> ;</p>
<p><span style="color: #0000ff;"><strong>The XML layout file</strong></span></p>
<p>By default, the XML file that defines the app&#8217;s layout is at <span style="color: #008000;"><code>res/layout/activity_maps.xml</code></span>. It contains the following code or add the following code:</p>
<pre><code><;?xml version="1.0" encoding="utf-8"?>;
<;fragment xmlns:android="http://schemas.android.com/apk/res/android"
 xmlns:map="http://schemas.android.com/apk/res-auto"
 xmlns:tools="http://schemas.android.com/tools"
 android:id="@+id/map"
 android:name="com.google.android.gms.maps.SupportMapFragment"
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 tools:context=".MapsActivity" />;</code></pre>
<p> ;</p>
<p id="the_maps_activity_java_file"><span style="color: #0000ff;"><strong>The maps activity Java file</strong></span></p>
<pre><code>package c1c.googlemapexample;

import android.support.v4.app.FragmentActivity;
import android.os.Bundle;

import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;

public class MapsActivity extends FragmentActivity implements OnMapReadyCallback {

 private GoogleMap mMap;

 @Override
 protected void onCreate(Bundle savedInstanceState) {
 super.onCreate(savedInstanceState);
 setContentView(R.layout.activity_maps);
 <strong><span style="color: #008000;">// Obtain the SupportMapFragment and get notified when the map is ready to be used.</span></strong>
 SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
 .findFragmentById(R.id.map);
 mapFragment.getMapAsync(this);
 }

 @Override
 public void onMapReady(GoogleMap googleMap) {
 mMap = googleMap;

 // Add a marker in Sydney and move the camera
 LatLng sydney = new LatLng(-34, 151);
 mMap.addMarker(new MarkerOptions().position(sydney).title("Marker in Sydney"));
 mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney));
 }
}</code></pre>
<p> ;</p>
<p><span style="color: #0000ff;"><strong>Run the app:</strong></span></p>
<p><img class="aligncenter wp-image-442 size-full" src="https://c1ctech.com/wp-content/uploads/2018/05/Screenshot-2018-05-19-21.20.07.png" alt="" width="482" height="802" /></p>
<p> ;</p>


