SDKsAndroid
Create an image message from a local path
Create an image message from an absolute path.
Construct an image message object from an absolute filesystem path on the local device (such as an image picked from the photo gallery or captured by the camera). When sending via Send a message, the SDK reads the local file and automatically performs compression and upload.
Code example
String absolutePath = "/storage/emulated/0/Pictures/chat_image.png";
Message message = OpenIMClient.getInstance().messageManager.createImageMessageFromFullPath(absolutePath);Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
imagePath | String | Yes | Absolute filesystem path of the image file on the local device. Ensure read permissions are granted. |
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 deliver the image to a single user or group.
Was this page helpful?