title: Adding Markers on Google maps v2 Android
body: <p>I followed the tutorial in </p>
  
  <pre><code>https://developers.google.com/maps/documentation/android/start
  </code></pre>
  
  <p>and i managed to load a map into my app.Now i want to add some markers into my app using latitudes and longitudes.How do i do it? I tried something but did not work. The code i tried is below.</p>
  
  <p>This how i was going to do it.But i get a null point exception.What is the reason for that?</p>
  
  <pre><code>GoogleMap googleMap = null;
  
             MapFragment fm = (MapFragment) (activity.getFragmentManager())
                      .findFragmentById(R.id.map);
  
             googleMap = fm.getMap();
  
              double latitude = 7.421226;
              double longitude =80.401264 ;
  
              // create marker
              MarkerOptions marker = new MarkerOptions().position(new LatLng(latitude, longitude)).title("Hello Maps ");
  
              // adding marker
              googleMap.addMarker(marker); 
  </code></pre>
  
  <p>My layout</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="vertical"
      android:id="@+id/filmhall"
      android:background="@color/grey" &gt;
  
  
  
  &lt;fragment 
            android:id="@+id/map"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:name="com.google.android.gms.maps.SupportMapFragment"/&gt; 
  
  &lt;/LinearLayout&gt;
  </code></pre>