title: How to add marker on map by double tap and get the coordinates [android]
body: <p>I want to add marker on google map by double tap. I know about <strong>googlemap.OnMapClickListener</strong> but it adds a marker on single tap. I have found a post on handling double tap in google map but i am unable to add marker from another class.</p>
  
  <p><strong>MapFragment.java:</strong></p>
  
  <pre><code>        @Override
          public View onCreateView(LayoutInflater inflater, final ViewGroup container,
                                   Bundle savedInstanceState) {
              // Inflate the layout for this fragment
              View view = inflater.inflate(R.layout.fragment_map, container, false);
  
              mMapView = (MapView) view.findViewById(R.id.mapView);
              mMapView.onCreate(savedInstanceState);
  
              mMapView.onResume(); // needed to get the map to display immediately
  
              try {
                  MapsInitializer.initialize(getActivity().getApplicationContext());
              } catch (Exception e) {
                  e.printStackTrace();
              }
  
              mMapView.getMapAsync(new OnMapReadyCallback() {
                  @Override
                  public void onMapReady(GoogleMap mMap) {
                      googleMap = mMap;
  
                      if (latitude != null &amp;&amp; longitude != null) {
                          // For showing a move to my location button
                          if (ActivityCompat.checkSelfPermission(getActivity(), Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED &amp;&amp; ActivityCompat.checkSelfPermission(getActivity(), Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED)
                          {
                              return;
                          }
                          googleMap.setMyLocationEnabled(true);
  
                          // For dropping a marker at a point on the Map
                          final LatLng coordinates = new LatLng(latitude, longitude);
  
                          // For zooming automatically to the location of the marker
                          cameraPosition = new CameraPosition.Builder().target(coordinates).zoom(15).build();
                          googleMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
  
                          googleMap.setOnMapClickListener(new GoogleMap.OnMapClickListener() {
                              @Override
                              public void onMapClick(final LatLng coordinates){
  
                              **//adds marker on single tap &amp; get coordinates**//
  
                              }
                          });
  
                      }
  
                  }
  
              });
  
              return view;
          }
  
  @Override
  public boolean onDoubleTap(MotionEvent e) {
  
      return true; 
  }
  
  // Here will be some autogenerated methods too
  </code></pre>
  
  <p><strong>Map Fragment.xml:</strong></p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:orientation="vertical"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"&gt;
  
      &lt;azizbekyan.andranik.map.OnDoubleTap
          android:id="@+id/mapView"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"
          android:enabled="true"
          android:clickable="true"
          android:apiKey="YOUR_API_KEY" /&gt;        
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p><strong>OnDoubleTap.java:</strong></p>
  
  <pre><code>    public class OnDoubleTap extends MapView {
  
    private long lastTouchTime = -1;
  
    public OnDoubleTap(Context context, AttributeSet attrs) {
      super(context, attrs);
    }
  
    @Override
    public boolean onInterceptTouchEvent(MotionEvent ev) {
      if (ev.getAction() == MotionEvent.ACTION_DOWN) {
        long thisTime = System.currentTimeMillis();
        if (thisTime - lastTouchTime &lt; ViewConfiguration.getDoubleTapTimeout()) {
          //** Double tap control here **//
  
          lastTouchTime = -1;
        } else {
          // Too slow 
          lastTouchTime = thisTime;
        }
      }
      return super.onInterceptTouchEvent(ev);
    }
  }
  </code></pre>
  
  <p>Now how can I add marker on google map by double tap and get the coordinates from another class? Any help would be appreciated.</p>