title: Unable to get place details by place id
body: <p>I want to get the gas stations near to my location. For this I used web api which gives id,lat,long of the places.
  Now I want to get the details of the place like name,reviews etc. </p>
  
  <p>How can I find the same?</p>
  
  <p>I have tried to use the listener but it does not run at all.</p>
  
  <pre><code>public class GetLocationsAsyncTask extends AsyncTask&lt;String, Void, JSONObject&gt; {
  
      String api;
      JSONObject jsonParams;
      Context mContext;
      private ProgressDialog loadingDialog;
      private CoordinatorLayout parentLayout;
      private GetLocationsCallBack getLocationsCallBack;
      private ArrayList&lt;Location&gt; locationArrayList;
      private String latitude,longitude;
      protected GeoDataClient mGeoDataClient;
      private CharSequence pumpName;
  
      public GetLocationsAsyncTask(Context context, GetLocationsCallBack getLocationsCallBack) {
  
          this.mContext = context;
          this.getLocationsCallBack = getLocationsCallBack;
  
      }
  
      public GetLocationsAsyncTask(Context context) {
  
          this.mContext = context;
      }
  
      public interface GetLocationsCallBack {
          void doPostExecute(ArrayList&lt;Location&gt; list);
      }
  
      @Override
      protected void onPreExecute() {
          super.onPreExecute();
  
              loadingDialog = ProgressDialog.show(mContext, null,"WAIT");
              loadingDialog.setCancelable(false);
      }
  
      @Override
      protected JSONObject doInBackground(String... params) {
          try {
  
              api = "https://maps.googleapis.com/maps/api/place/radarsearch/json?location=19.155148,72.867855&amp;radius=5000&amp;type=gas_station&amp;keyword=bharat&amp;key=AIzaSyCArRAX4oHdfFWrTW5dhXrO8hqV3VBQtbs";
  
  
              jsonParams = new JSONObject();
  
              ServerRequest request = new ServerRequest(api, jsonParams);
              return request.sendGetRequest();
  
          } catch (Exception ue) {
              return Excpetion2JSON.getJSON(ue);
          }
      }  //end of doInBackground
  
      @Override
      protected void onPostExecute(JSONObject response) {
          super.onPostExecute(response);
  
          try {
              mGeoDataClient = Places.getGeoDataClient(mContext, null);
  
  
              if (response.has("results")) {
  
  
                  JSONArray jsonArray = response.getJSONArray("results");
  
  
                  locationArrayList = new ArrayList&lt;&gt;();
  
                  for (int i = 0; i &lt; jsonArray.length(); i++) {
  
                      final Location location = new Location();
  
  
                      JSONObject jsonObject = jsonArray.getJSONObject(i);
  
                      JSONObject geometry = jsonObject.getJSONObject("geometry");
  
                      final String placeId = jsonObject.getString("place_id");
  
                      JSONObject locationObject = geometry.getJSONObject("location");
  
                      latitude = locationObject.getString("lat");
                      longitude = locationObject.getString("lng");
  
                      mGeoDataClient.getPlaceById(placeId).addOnCompleteListener(new OnCompleteListener&lt;PlaceBufferResponse&gt;() {
                          @Override
                          public void onComplete(@NonNull Task&lt;PlaceBufferResponse&gt; task) {
                              if (task.isSuccessful()) {
                                  PlaceBufferResponse places = task.getResult();
                                  Place myPlace = places.get(0);
                                  Log.i(TAG, "Place found: " + myPlace.getName());
  
                                  pumpName =  myPlace.getName();
  
                                  location.setPumpName(String.valueOf(pumpName));  // this all does not run.I need to get the name of place by place Id.
  
                                  places.release();
                              } else {
                                  Log.e(TAG, "Place not found." + placeId);
                              }
                          }
                      });
  
                      location.setLocation(getAddress(latitude,longitude,placeId));
  
                      locationArrayList.add(location);
                  }
  
                  if (getLocationsCallBack != null)
                      getLocationsCallBack.doPostExecute(locationArrayList);
  
                  if (loadingDialog.isShowing())
                      loadingDialog.dismiss();
              }
  
          } catch (JSONException je) {
  
              je.printStackTrace();
          }
      } //end of onPostExecute
  
      public String getAddress(String latitude, String longitude, final String placeId) {
          String address = "";
          try {
  
              Geocoder geocoder;
              List&lt;Address&gt; addresses;
              geocoder = new Geocoder(mContext, Locale.getDefault());
  
              addresses = geocoder.getFromLocation(Double.parseDouble(latitude), Double.parseDouble(longitude), 1); // Here 1 represent max location result to returned, by documents it recommended 1 to 5
              address = addresses.get(0).getAddressLine(0); // If any additional address line present than only, check with max available address lines by getMaxAddressLineIndex()
              String city = addresses.get(0).getLocality();
              String state = addresses.get(0).getAdminArea();
              String country = addresses.get(0).getCountryName();
              String postalCode = addresses.get(0).getPostalCode();
              String knownName = addresses.get(0).getFeatureName();
  
  
          } catch (IOException ie) {
              ie.printStackTrace();
          }
          return address;
      }
  }
  </code></pre>
  
  <p>Also I have another api which gives details of place by place id, but I want to show the name in my places list only, how can I call details api for every place from place list and show in same list?</p>
  
  <p><a href="https://maps.googleapis.com/maps/api/place/details/json?placeid=ChIJ02Q611O25zsRVi5Xs9NKmhc&amp;key=AIzaSyCArRAX4oHdfFWrTW5dhXrO8hqV3VBQtbs" rel="nofollow noreferrer">https://maps.googleapis.com/maps/api/place/details/json?placeid=ChIJ02Q611O25zsRVi5Xs9NKmhc&amp;key=AIzaSyCArRAX4oHdfFWrTW5dhXrO8hqV3VBQtbs</a></p>
  
  <p>Above is the place details api.</p>
  
  <p>Please help,Thank you.</p>