public class

Image

extends Event
implements Parcelable
java.lang.Object
   ↳ com.nexmo.sdk.conversation.client.Event
     ↳ com.nexmo.sdk.conversation.client.Image

Class Overview

Send an image to a Conversation and handle activity receipts. The following code example shows how to send an image to a Conversation:

 conversation.sendImage("imagePath", new ImageSendListener() {
          @Override
          public void onSuccess(Event image) {
          }

          @Override
          public void onError(NexmoAPIError error) {
          }
      });
 

Once the image is uploaded, you will be able to access all 3 representations:

Each ImageRepresentationcan be asynchronously downloaded using download(ImageRepresentation.TYPE, RequestHandler)

Alternatively, you can use any other 3rd party image handling library to download the image, based on getUrl()

For listening to incoming/sent messages events, register using messageEvent()

Note: No payload is supported for images. Use Text instead for sending text messages.

Summary

[Expand]
Inherited Constants
From interface android.os.Parcelable
Fields
public static final Creator<Image> CREATOR
[Expand]
Inherited Fields
From class com.nexmo.sdk.conversation.client.Event
Protected Constructors
Image(String localPath)
Image(String id, Date timestamp)
Image(String id, Date timestamp, Member member)
Image(String id, Date timestamp, Member member, Conversation conversation)
Image(String id, Date timestamp, Member member, Conversation conversation, ImageRepresentation original, ImageRepresentation medium, ImageRepresentation thumbnail)
Image(String id, Date timestamp, Member member, Date deletedTimestamp)
Image(String id, Date timestamp, Member member, Date deletedTimestamp, Conversation conversation)
Image(String id, Date timestamp, Member member, Date deletedTimestamp, Collection<SeenReceipt> seenReceipts)
Image(String id, Date timestamp, Member member, Date deletedTimestamp, Conversation conversation, Collection<SeenReceipt> seenReceipts)
Image(String id, Date timestamp, Member member, Date deletedTimestamp, Conversation conversation, ImageRepresentation original, ImageRepresentation medium, ImageRepresentation thumbnail, Collection<SeenReceipt> seenReceipts, Collection<DeliveredReceipt> deliveredReceipts)
Image(String id, Date timestamp, Member member, Date deletedTimestamp, Conversation conversation, Collection<SeenReceipt> seenReceipts, Collection<DeliveredReceipt> deliveredReceipts)
Image(Image message)
Image(Parcel in)
Public Methods
int describeContents()
void download(ImageRepresentation.TYPE type, RequestHandler downloadListener)
Start downloading an image representation.
boolean equals(Object o)
static Image fromPush(String senderId, String eventId, JSONObject messageObject)
ImageRepresentation getImageRepresentationByType(ImageRepresentation.TYPE type)
ImageRepresentation getMedium()
ImageRepresentation getOriginal()
ImageRepresentation getThumbnail()
EventType getType()
int hashCode()
boolean isDownloaded()
Check if THUMBNAIL image representation was already downloaded on local storage.
String toString()
void writeToParcel(Parcel dest, int flags)
[Expand]
Inherited Methods
From class com.nexmo.sdk.conversation.client.Event
From class java.lang.Object
From interface android.os.Parcelable

Fields

public static final Creator<Image> CREATOR

Protected Constructors

protected Image (String localPath)

protected Image (String id, Date timestamp)

protected Image (String id, Date timestamp, Member member)

protected Image (String id, Date timestamp, Member member, Conversation conversation)

protected Image (String id, Date timestamp, Member member, Conversation conversation, ImageRepresentation original, ImageRepresentation medium, ImageRepresentation thumbnail)

protected Image (String id, Date timestamp, Member member, Date deletedTimestamp)

protected Image (String id, Date timestamp, Member member, Date deletedTimestamp, Conversation conversation)

protected Image (String id, Date timestamp, Member member, Date deletedTimestamp, Collection<SeenReceipt> seenReceipts)

protected Image (String id, Date timestamp, Member member, Date deletedTimestamp, Conversation conversation, Collection<SeenReceipt> seenReceipts)

protected Image (String id, Date timestamp, Member member, Date deletedTimestamp, Conversation conversation, ImageRepresentation original, ImageRepresentation medium, ImageRepresentation thumbnail, Collection<SeenReceipt> seenReceipts, Collection<DeliveredReceipt> deliveredReceipts)

protected Image (String id, Date timestamp, Member member, Date deletedTimestamp, Conversation conversation, Collection<SeenReceipt> seenReceipts, Collection<DeliveredReceipt> deliveredReceipts)

protected Image (Image message)

protected Image (Parcel in)

Public Methods

public int describeContents ()

public void download (ImageRepresentation.TYPE type, RequestHandler downloadListener)

Start downloading an image representation. The downloaded image will be cached to local storage. Next time download is called, image will be fetched from local storage, if file still exists.

Parameters
type Any of ORIGINAL, MEDIUM, or THUMBNAIL
downloadListener The listener in charge of dispatching the completion result. When onSuccess() is triggered, either the file, or the associated bitmap can be accessed to update UI:
  • getBitmap(). Note: bitmaps are recycled on disconnection only, so make sure to recycle them when not used to avoid OutOfMemory.
  • getLocalFilePath() to decode from file.

public boolean equals (Object o)

public static Image fromPush (String senderId, String eventId, JSONObject messageObject)

Throws
JSONException

public ImageRepresentation getImageRepresentationByType (ImageRepresentation.TYPE type)

public ImageRepresentation getMedium ()

public ImageRepresentation getOriginal ()

public ImageRepresentation getThumbnail ()

public EventType getType ()

public int hashCode ()

public boolean isDownloaded ()

Check if THUMBNAIL image representation was already downloaded on local storage.

Path: "storage/emulated/0/AppPackageName/Media/Images/IMG-imageTimestamp-imageRepresentationID-imageRepresentationType.jpg" Where imageTimestamp is getTimestamp() , imageRepresentationID is ImageRepresentation#id and imageRepresentationType is type

public String toString ()

public void writeToParcel (Parcel dest, int flags)