SDKsAndroid
Create an image message
Create an image message from a path relative to the SDK data directory.
Construct an image message object from a file path relative to the SDK initialization data directory. When sending via Send a message, the SDK automatically compresses the image and uploads the file.
Code example
String imagePath = "images/pic_001.jpg"; // Path relative to SDK data directory
Message message = OpenIMClient.getInstance().messageManager.createImageMessage(imagePath);Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
imagePath | String | Yes | File path of the image relative to the SDK initialization data directory. |
Return value
Returns the created Message object with contentType set to MessageType.PICTURE.
State changes after the call
- Local initialization: Initializes the local
Messagestructure without initiating network uploads. - Transmission: Call Send a message to upload and send the image. For absolute local file paths, see Create an image message from a local path.
Was this page helpful?