SDKsAndroid
Create a location message
Use createLocationMessage to create a message with coordinates and a location description.
Construct a location message object containing geographic coordinates (latitude and longitude) and a detailed textual address. This is typically used to share current location pins or place cards within a chat.
Code example
double latitude = 39.9042;
double longitude = 116.4074;
String description = "Tiananmen Square, Dongcheng District, Beijing";
Message message = OpenIMClient.getInstance().messageManager.createLocationMessage(
latitude,
longitude,
description
);Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
latitude | double | Yes | Latitude coordinate, valid from -90.0 to 90.0. |
longitude | double | Yes | Longitude coordinate, valid from -180.0 to 180.0. |
description | String | Yes | Place name or detailed textual address displayed to recipients. |
Return value
Returns the created Message object with contentType set to MessageType.LOCATION.
State changes after the call
- Local initialization: Initializes the local
Messagestructure without prompting for location permissions or sending data to the server. - Transmission: Call Send a message to deliver the location message to a single user or group.
Was this page helpful?