In-app Chat
  • iOS
  • Android : Java
  • Web
  • Flutter
  • React Native
  • Unity3D
  • Windows
  • macOS
  • Introduction
    • Overview
    • Basic concepts
  • Sample app
  • Getting started
  • Client SDKs
    • SDK downloads
    • Release notes
  • Guides
    • Authentication
    • Manage users
    • Room
    • Group
    • Messaging
    • Call invitation (signaling)
    • Manage sessions
  • Offline push notifications
  • Error codes
  • Client APIs
  • Server APIs

Sample app

Last updated:2023-09-27 10:16
Sample app

Here we provide you with a sample application to experience ZEGOCLOUD's In-app Chat, and also describe how to run the sample code.


  • Android Studio 2.1 or later.
  • Android SDK Packages: Android SDK 28, Android SDK Platform-Tools 28.x.x or later.
  • An Android device or Simulator that is running on Android 4.1 or later and supports audio and video. We recommend you use a real device (Remember to enable the USB debugging).
  • The Android device is connected to the internet.
  • Contact the ZEGOCLOUD Technical support to get the AppID and ServerSecret for SDK integration.
  • Get the token that SDK required for login authentication. For details, see Authentication.
  • When you compile the sample code for the first time, if you do not have the corresponding dependent library or build tool, Android Studio will automatically download the sample code. This may take a while for you to wait.
  • We recommend you download the specified gradle and required dependencies. To download, go to Gradle Services. The gradle we use in the sample code are as follows:
    • gradle: 4.6 (check it in the project/gradle/wrapper/ file).
    • gradle Android plug-in: 3.2.1 (check it in the project/build.gradle file).

Sample code structure

The following structure shows the subdirectory structure of the In-app Chat sample code:

├── app
│   ├── agconnect-services.json
│   ├── build
│   │   ├── generated
│   │   ├── intermediates
│   │   ├── outputs
│   │   └── tmp
│   ├── build.gradle
│   ├── libs
│   │   ├── MiPush_SDK_Client_4_9_1.jar
│   │   ├── VERSION.txt
│   │   ├── ZIM.jar
│   │   ├── arm64-v8a
│   │   ├── armeabi-v7a
│   │   ├── pushOpenClient_v3.0.0.4_484_81c1f83_release.jar
│   │   ├── x86
│   │   ├── x86_64
│   │   └── zpns-release.aar
│   ├──
│   ├── src
│   │   └── main
│   └── zim_example_key.jks
├── build.gradle
├── gradle
│   └── wrapper
│       ├── gradle-wrapper.jar
│       └──
├── gradlew
├── gradlew.bat
└── settings.gradle

Run the sample code

  1. In Android Studio, click Open an Existing Project.

  2. Open the ZIMExampleJava folder in the unzipped sample code package.


  3. Go to the SDK downloads to download the latest version of SDK, copy the unzipped SDK package file to the app/libs directory.

  4. Modify the file under the ZIMExample/app/src/main/java/im/zego/zimexample folder with the AppID and ServerSecret (remember to add a "L" after the AppID) that you get in the Prerequisites steps.


  5. Connect the Android device to your computer, after you enabled the developer mode and USB debugging on the device, the option box in the upper place of Android Studio changes like the following, which means you are ready to run the sample code on the Android device.





<div class = 'mk-hint'>

- When you connect your PC to an Android device, a message will pop up on most devices. The message varies according to Android vendors. You can select USB mode according to the actual situation.
- After the Android device is connected to your computer, you will need to enable the **developer mode*8 and **USB debugging** on the device based on the actual situation. You can search for specific enabling methods by yourself.
  1. Click the Run button to run the sample code and experience the In-app Chat service.


This error error: incompatible types: unexpected return value occurs when Android Studio runs the sample code.


The AppID and ServerSecret in our sample code This is because there are no specific values for AppID and ServerSecret in the sample code you downloaded. Please follow the Prerequisites to get the AppID and ServerSecret first and try again.

Page Directory