title: Get Image on Google Maps Android
body: <p>I am using Google Maps API in my app, when I search a location and click information button, it will show a windows with name, address, image.
  I copied func getPhoto() from google maps doc:</p>
  
  <pre><code>private Bitmap getPhotos() {
  
      Task&lt;PlacePhotoMetadataResponse&gt; photoMetadataResponse = mGeoDataClient.getPlacePhotos(Maps.mPlace.getId());
      photoMetadataResponse.addOnCompleteListener(new OnCompleteListener&lt;PlacePhotoMetadataResponse&gt;() {
          @Override
          public void onComplete(@NonNull Task&lt;PlacePhotoMetadataResponse&gt; task) {
              try {
                  // Get the list of photos.
                  PlacePhotoMetadataResponse photos = task.getResult();
                  // Get the PlacePhotoMetadataBuffer (metadata for all of the photos).
                  PlacePhotoMetadataBuffer photoMetadataBuffer = photos.getPhotoMetadata();
                  // Get the first photo in the list.
                  PlacePhotoMetadata photoMetadata = photoMetadataBuffer.get(0);
                  // Get the attribution text.
                  CharSequence attribution = photoMetadata.getAttributions();
                  // Get a full-size bitmap for the photo.
                  Task&lt;PlacePhotoResponse&gt; photoResponse = mGeoDataClient.getPhoto(photoMetadata);
  
                  photoResponse.addOnCompleteListener(new OnCompleteListener&lt;PlacePhotoResponse&gt;() {
                      @Override
                      public void onComplete(@NonNull Task&lt;PlacePhotoResponse&gt; task) {
                          PlacePhotoResponse photo = task.getResult();
                          bitmap = photo.getBitmap();
                          ImageView imageView = mWindow.findViewById(R.id.imageView);
  
                          imageView.setImageBitmap(bitmap);
  
                          imageView.refreshDrawableState();
  
                      }
                  });
              } catch (IllegalStateException e) {
                  Log.e("aaa", "onComplete: IllegalStateException: " + e.getMessage() );
              }
          }
      });
      return bitmap;
  }
  </code></pre>
  
  <p>And I place it into a func to get imformation:</p>
  
  <pre><code>private void rendowWindowText (Marker marker, View view) {
      String title = marker.getTitle();
      TextView tvTitle = view.findViewById(R.id.txt_title);
  
      if (!title.equals("")) {
          tvTitle.setText(title);
      }
  
      String snippet = marker.getSnippet();
      TextView tvSnippet = view.findViewById(R.id.txt_snippet);
  
      if (!title.equals("")) {
          tvSnippet.setText(snippet);
      }
  
      getPhotos();
  
  }
  </code></pre>
  
  <p>Now my problem is when I search a place and hit button to show marker's info, my imageview is nothing:</p>
  
  <p><a href="https://i.stack.imgur.com/cTkcW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cTkcW.png" alt="green background in my xml"></a></p>
  
  <p>And when I click that button to close windows and click again to show marker's info, the image is loaded: </p>
  
  <p><a href="https://i.stack.imgur.com/2yCa6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2yCa6.png" alt="enter image description here"></a></p>
  
  <p>Somebody can tell me how to fix that? Thank you very much!</p>