title: Creating markers with onClickListener that opens AlertDialog dynamically
body: <p>I'm trying to add markers to the map dynamically, getting the data from JSON, and that part is working, I can add multiple marker in multiple places, but when I click on the marker I want that a alert dialog opens, this alert dialog must contain some information regarding that marker, but right now the information I have is always the same, it's like if the the creation of the alert dialog is not in the same cycle that creates the marker.</p>
  
  <p>See my code:</p>
  
  <pre><code>final JSONArray array = new JSONArray(jsonStrOportunidades);
  for (int i = 0; i &lt; array.length(); i++)
  {
      JSONObject jsonObject = array.getJSONObject(i);
      final String Designacao = jsonObject.getString("Designacao");
      String Coord_LAT = jsonObject.getString("Coord_LAT");
      String Coord_LONG = jsonObject.getString("Coord_LONG");
      final String Morada = jsonObject.getString("Morada");
  
      final HashMap&lt;String, String&gt; oportunidades = new HashMap&lt;&gt;();
  
      oportunidades.put("Designacao", Designacao);
      oportunidades.put("Coord_LAT", Coord_LAT);
      oportunidades.put("Coord_LONG", Coord_LONG);
      oportunidades.put("Morada", Morada);
  
      double lat1 = Double.parseDouble(Coord_LAT);
      double lng1 = Double.parseDouble(Coord_LONG);
  
      mMap.addMarker(new MarkerOptions().position(new LatLng(lat1, lng1)));
  
      mMap.setOnMarkerClickListener(new GoogleMap.OnMarkerClickListener() {
          @Override
          public boolean onMarkerClick(Marker marker) {
              new AlertDialog.Builder(MapsActivity.this)
                      .setTitle(Designacao)
                      .setMessage("Endereço: " + Morada + "\n" + "Telefone: " )
                      .setPositiveButton("Ir", new DialogInterface.OnClickListener() {
                          public void onClick(DialogInterface dialog, int which) {
                              new GetDirecoes().execute();//Enviar as coordenadas
                              mBottomSheetBehavior.setPeekHeight(250);
                          }
                      })
                      .setNegativeButton("Cancelar", new DialogInterface.OnClickListener() {
                          public void onClick(DialogInterface dialog, int which) {
                              // do nothing
                          }
                      })
                      .show();
              return false;
          }
      });
      listaOportunidades.add(oportunidades);
  } 
  </code></pre>