I have found a solution after a couple of hours of frustration.
By calling getContentType(
) on the response back from the API, I was able to identify that the response is simply an image of a given type. In my case I found it to be "text/jpeg". You can retrieve the InputStream
of the content by calling getContent()
.
BitmapFactory
class allows you to decode an InputStream
into a Bitmap
.
Bitmap photo = BitmapFactory.decodeStream(request.execute().getContent());
In order to display this image, I first needed to set a custom view for the DialogBuilder
.
LayoutInflater factory = LayoutInflater.from(mapView.getContext());
final View view = factory.inflate(R.layout.dialog_layout, null);
dialog.setView(view);
Next, I get the photo response and add it to the ImageView
in the layout (which is already defined in the XML):
LinearLayout ll = (LinearLayout) view.findViewById(R.id.dialogLayout);
ImageView imageView = (ImageView) ll.findViewById(R.id.placePhoto);
imageView.setImageBitmap(photo);
It is important to note that the Place Details response can send back up to 10 photos. You can't guarantee that the "best" photo will be sent back. In my case, I take the first one.