Attachments & Media
Attachments:
- ICAttachment
- ICAudioAttachment
- ICImageAttachment
- ICLocationAttachment
- ICMediaAttachment
- ICVideoAttachment
Media Management:
ICAttachment
The base class for message attachments, exposes elements common to all types of attachments.
Attachments can be present on both incoming and outgoing messages.
Public Methods:
Return Type | Method |
---|---|
String | getContentType() |
void | setContentType(String contentType) |
JSONObject | toJSON() |
getContentType
Gets the content type of the attachment, such as image/video/location.
Syntax: String getContentType()
Return Value: Returns the content type.
setContentType
Set the content type of the attachment.
Syntax: void setContentType(String contentType)
Parameters:
Parameter | Type | Description |
---|---|---|
contentType | String | The content type. |
toJSON
Returns a new JSONObject instance containing attachment data.
Syntax: JSONObject toJSON()
Return Value: A JSONObject representation of the attachment.
ICAudioAttachment
Represents an audio file attachment.
Return Type | Method |
---|---|
ICAudioAttachment | fromJSON(JSONObject jsonObj) |
long | getDuration() |
void | setDuration(long duration) |
Instantiates a new ICAudioAttachment instance from the supplied JSONObject.
The JSONObject must contain valid audio attachment data.
Syntax: static ICAudioAttachment fromJSON(JSONObject jsonObj)
Return Value: A new ICAudioAttachment or null if jsonObj is null.
Parameters:
Parameter | Type | Description |
---|---|---|
jsonObj | JSONObject | A valid JSONObject instance containing audio attachment data. |
getDuration
Returns the audio attachment duration, in seconds.
Syntax: long getDuration()
Return Value: The audio attachment duration, in seconds.
setDuration
Sets the audio attachment duration, in seconds.
Syntax: void setDuration(long duration)
Parameters:
Parameter | Type | Description |
---|---|---|
duration | int | Specifies the duration in seconds. |
ICImageAttachment
Represents an Image attachment.
Return Type | Method |
---|---|
ICImageAttachment | [fromJSON(JSONObject jsonObj)](#section-fromjson-a-image-) |
Bitmap | [getPreviewImage()](#section-getpreviewimage) |
void | [setPreviewImage(Bitmap preview)](#section-setpreviewimage) |
Instantiates a ICImageAttachment from a JSONObject. The JSONObject must contain valid image attachment data.
Syntax: static ICImageAttachment fromJSON(JSONObject jsonObj)
Return Value: A new ICImageAttachment instance, or null if jsonObj is null.
Parameters:
Parameter | Type | Description |
---|---|---|
jsonObj | JSONObject | A JSONObject containing valid image attachment data. |
getPreviewImage
Gets the attachment preview image as a bitmap.
Syntax: Bitmap getPreviewImage()
Return Value: A bitmap containing the preview image, or null if there is no preview.
setPreviewImage
Sets the attachment preview image.
Syntax: void setPreviewImage(Bitmap preview)
Parameters:
Parameter | Type | Description |
---|---|---|
preview | Bitmap | A Bitmap object containing the preview image. |
ICLocationAttachment
Represents location data that may be attached to a message.
Location data is comprised of latitude and longitude.
Return Type | Method |
---|---|
ICLocationAttachment | [fromJSON(JSONObject jsonObj)](#section-fromjson-a-location-) |
double | [getLatitude()](#section-getlatitude) |
double | [getLongitude()](#section-getlongitude) |
void | [setLatitude(double latitude)](#section-setlatitude) |
void | [setLongitude(double longitude)](#section-setlongitude) |
Returns a new ICLocationAttachment instantiated from data contained within a JSONObject. The JSONObject must contain valid location attachment data.
Syntax: static ICLocationAttachment fromJSON(JSONObject jsonObj)
Return Value: A new ICLocationAttachment instance, or null if jsonObj is null.
Parameters:
Parameter | Type | Description |
---|---|---|
jsonObj | JSONObject | A JSONObject instance containing valid location attachment data. |
getLatitude
Gets the latitude value.
Syntax: double getLatitude()
Return Value: The latitude value.
getLongitude
Gets the longitude value.
Syntax: double getLongitude()
Return Value: The longitude value.
setLatitude
Sets the latitude value.
Syntax: void setLatitude(double latitude)
Parameters:
Parameter | Type | Description |
---|---|---|
latitude | double | Specifies the latitude value. |
setLongitude
Sets the longitude value.
Syntax: void setLongitude(double longitude)
Parameters:
Parameter | Type | Description |
---|---|---|
longitude | double | Specifies the longitude value. |
ICMediaAttachment
Base class for message attachments which exposes data common to all types of media file.
Return Type | Method |
---|---|
String | [getMediaId()](#section-getmediaid) |
long | [getSize()](#section-getsize) |
URL | [getURL()](#section-geturl) |
void | [setMediaId(String mediaId)](#section-setmediaid) |
void | [setSize(long size)](#section-setsize) |
void | [setURL(URL url)](#section-seturl) |
getMediaId
Gets the id of the media attachment hosted within the IMIconnect platform.
Syntax: String getMediaId()
Return Value: Returns the id of the media attachment.
getSize
Gets the media file attachment size, in bytes.
Syntax: long getSize()
Return Value: Returns the file size of the media attachment, in bytes.
getURL
Returns the attachment URL.
Syntax: URL getURL()
Return Value: Returns the attachment URL.
setMediaId
Sets the id of the media attachment.
Syntax: void setMediaId(String id)
Parameters:
Parameter | Type | Description |
---|---|---|
id | string | Specifies the id of the attachment. |
setSize
Sets the size of the attachment, in bytes.
Syntax: void setSize(long size)
Parameters:
Parameter | Type | Description |
---|---|---|
size | integer | Specifies the size of the attachment, in bytes. |
setURL
Sets the URL of the media attachment.
Syntax: void setURL(URL url)
Parameters:
Parameter | Type | Description |
---|---|---|
url | URL | Specifies the URL of the media attachment. |
ICVideoAttachment
Represents an attachment that contains video data.
Return Type | Method |
---|---|
ICVideoAttachment | [fromJSON(JSONObject jsonObj)](#section-fromjson-a-video-) |
long | [getDuration()](#section-getduration-a-video-) |
Bitmap | [getPreviewImage()](#section-getpreviewimage-a-video-) |
void | [setDuration(long duration)](#section-setduration-a-video-) |
void | [setPreviewImage(Bitmap image)](#section-setpreviewimage-a-video-) |
Instantiates a ICVideoAttachment from a JSONObject. The JSONObject must contain valid video attachment data.
Syntax: static ICVideoAttachment fromJSON(JSONObject jsonObj)
Return Value: A new ICVideoAttachment instance, or null if jsonObj is null.
Parameters:
Parameter | Type | Description |
---|---|---|
jsonObj | JSONObject | A JSONObject instance containing valid video attachment data. |
Gets the duration of the video attachment, in seconds.
Syntax: long getDuration()
Return Value: The duration of the video attachment, in seconds.
Gets the video attachment preview image as a bitmap.
Syntax: Bitmap getPreviewImage()
Return Value: The video attachment preview image as a bitmap, or null if no preview exists.
Sets the duration of the video attachment, in seconds.
Syntax: void setDuration(long duration)
Parameters:
Parameter | Type | Description |
---|---|---|
duration | int | Specifies the duration, in seconds. |
Sets the preview image of the video attachment.
Syntax: void setPreviewImage(Bitmap preview)
Parameters:
Parameter | Type | Description |
---|---|---|
preview | Bitmap | Specifies the preview image for the video attachment. |
ICMediaFileManager
Manages the process of uploading and downloading content for media file attachments.
Return Type | Method |
---|---|
void | [downloadFile(java.net.URL url, ICFileDownloadCallback callback](#section-downloadfile) |
File | [getCachedFile(java.net.URL url)](#section-getcachedfile) |
boolean | [isFileDownloading(java.net.URL url)](#section-isfiledownloading) |
boolean | [isFileUploading(File file)](#section-isfileuploading) |
void | [uploadFile(File file, ICFileUploadCallback callback)](#section-uploadfile) |
void | [uploadFile(File file, String mimeType, ICFileUploadCallback callback)](#section-uploadfile-a-mimetype-) |
downloadFile
Downloads a file from a URL.
Operates asynchronously and notifies the result via [ICFileDownloadCallback](doc:callbacks#section-icfiledownloadcallback)
Syntax: void downloadFile(URL url, ICFileDownloadCallback callback)
Parameters:
Parameter | Type | Description |
---|---|---|
url | URL | The URL of the file to be downloaded. |
callback | ICFileDownloadCallback | Invoked to report the result of the operation. |
getCachedFile
Used to obtain a previously downloaded file from the local file cache.
Syntax: File getCachedFile(URL url)
Return Value: A File instance, if the download exists in the cache, otherwise null.
Parameters:
Parameter | Type | Description |
---|---|---|
url | java.net.URL | The URL to be checked. |
isFileDownloading
Checks if the manager is currently downloading a file for the given URL.
Syntax: boolean isFileDownloading(java.net.URL url)
Return Value: True if the file is currently being downloaded.
Parameters:
Parameter | Type | Description |
---|---|---|
url | java.net.URL | The URL of the file that will be checked. |
isFileUploading
Checks if the manager is currently uploading a file to the IMIconnect platform.
Syntax: boolean isFileUploading(File file)
Return Value: True if the file is currently being uploaded.
Parameters:
Parameter | Type | Description |
---|---|---|
file | File | The local file to be checked. |
uploadFile
Used to upload a file to the IMIconnect platform.
This method attempts to infer the mime type of the file from the file extension, for more granular control use [uploadFile(File file, String mimeType, ICFileUploadCallback callback)](#section-uploadfile-a-mimetype-)
Syntax: void uploadFile(File file, ICFileUploadCallback callback)
Parameters:
Parameter | Type | Description |
---|---|---|
file | File | The local file to be uploaded. |
callback | [ICFileUploadCallback](doc:callbacks#section-icfileuploadcallback) | Invoked to report the result of the operation. |
Used to upload a file to the IMIconnect platform.
Syntax: void uploadFile(File file, String mimeType, ICFileUploadCallback callback)
Parameters:
Parameter | Type | Description |
---|---|---|
file | File | The local file to be uploaded. |
mimeType | String | The mimeType of the file. |
callback | [ICFileUploadCallback](doc:callbacks#section-icfileuploadcallback) | Invoked to report the result of the operation. |
Updated over 1 year ago