Introduction: IM Android
More: Author   ReportBugs   

Use this SDK to add instant messaging capabilities to your Android app. By connecting to a self-hosted OpenIM server, you can quickly integrate instant messaging capabilities into your app with just a few lines of code.

The underlying SDK core is implemented in OpenIM SDK Core. Using gomobile, it can be compiled into an AAR file for Android integration. Android interacts with the OpenIM SDK Core through JSON, and the SDK exposes a re-encapsulated API for easy usage. In terms of data storage, Android utilizes the SQLite layer provided internally by the OpenIM SDK Core.

Documentation 📚

Visit for detailed documentation and guides.

For the SDK reference, see

Installation 💻

Adding repositories

   maven { url '' }

Adding Dependencies

   implementation 'io.openim:android-sdk:3.4.1@aar'
   implementation 'io.openim:core-sdk:3.4.1-alpha.4@aar'
   implementation ''

Usage 🚀

The following examples demonstrate how to use the SDK.

Importing the SDK and initialize



  InitConfig initConfig = new InitConfig("Your IM server address",
            "Your IM server socket address", getStorageDir()); //Storage path
        initConfig.isLogStandardOutput = true;

        ///IM 初始化
        OpenIMClient.getInstance().initSDK('Your Application',
            initConfig, IMEvent.getInstance().connListener);

Logging In and Listening for Connection Status

Note1: You need to set up the listeners first and then log in.

// Set listener
 //User Profile Change Listener
 OpenIMClient.getInstance().userInfoManager.setOnUserListener(new OnUserListener() { });
 //Message-related Listener
 OpenIMClient.getInstance().messageManager.setAdvancedMsgListener(new OnAdvanceMsgListener() {});
 //Friendship Status Change Listener
 OpenIMClient.getInstance().friendshipManager.setOnFriendshipListener(new OnFriendshipListener() {});
 //Conversation-related Listener
 OpenIMClient.getInstance().conversationManager.setOnConversationListener(new OnConversationListener() {});
 //Group-related Listener
 OpenIMClient.getInstance().groupManager.setOnGroupListener(new OnGroupListener() { });

// Retrieve the profile of the currently logged-in user
 OpenIMClient.getInstance().login(new OnBase<String>() {
                            public void onError(int code, String error) {

                            public void onSuccess(String data) {
                                //Cache login information and start a delightful chat

                        }, userID, token);

To log into the IM server, you need to create an account and obtain a user ID and token. Refer to the access token documentation for details.

Receiving and Sending Messages 💬

OpenIM makes it easy to send and receive messages. By default, there is no restriction on having a friend relationship to send messages (although you can configure other policies on the server). If you know the user ID of the recipient, you can conveniently send a message to them.

Message  msg = OpenIMClient.getInstance().messageManager.createTextMessage("hello openim");
OpenIMClient.getInstance().messageManager.sendMessage(new OnMsgSendCallback() {
            public void onError(int code, String error) {
             // Failed to send message ❌

            public void onProgress(long progress) {

            public void onSuccess(Message message) {
             // Message sent successfully ✉️    

        }, msg, userID, groupID, null);

OpenIMClient.getInstance().messageManager.setAdvancedMsgListener(new OnAdvanceMsgListener(){
            public void onRecvNewMessage(Message msg) {
                // Received new message 📨

Examples 🌟

You can find a demo Android app that uses the SDK in the open-im-android-demo repository.

Community :busts_in_silhouette:

Community Meetings :calendar:

We want anyone to get involved in our community and contributing code, we offer gifts and rewards, and we welcome you to join us every Thursday night.

Our conference is in the OpenIM Slack 🎯, then you can search the Open-IM-Server pipeline to join

We take notes of each biweekly meeting in GitHub discussions, Our historical meeting notes, as well as replays of the meetings are available at Google Docs :bookmark_tabs:.

Who are using OpenIM :eyes:

Check out our user case studies page for a list of the project users. Don't hesitate to leave a 📝comment and share your use case.

License :page_facing_up:

OpenIM is licensed under the Apache 2.0 license. See LICENSE for the full license text.

About Me
GitHub: Trinea
Facebook: Dev Tools