All Products
Search
Document Center

Intelligent Media Services:Android guide

Last Updated:Dec 25, 2025

This topic describes how to integrate the Real-time Conversational AI agent into your Android application.

Source code description

Download the source code

You can download the source code from the open source project on GitHub.

Source code structure

├── Android       		// The root directory of the Android project.
│   ├── AUIBaseKits     // The basic components of AUI Kits.
│   ├── AUIAICall       // The UI components.
│   ├── README.md
│   ├── app             // The demo entry point.
│   ├── build.gradle  
│   └── settings.gradle

Environment requirements

  • Android Studio plugin version 4.1.3

  • Gradle 7.0.2

  • JDK 11 included with Android Studio

Prerequisites

You have developed the required API operations on your server or deployed the provided server source code. For more information, see Project deployment.

Run the demo

  1. After you download the source code, open the Android folder in Android Studio.

  2. Open the build.gradle project file and modify the package ID.

  3. Open the AUIAICallAgentIdConfig.java file to configure the agent ID and its region.

    // AUIAICallAgentIdConfig.java
    // Your voice call agent ID.
    private static String VOICE_AGENT_ID = "<Your voice call agent ID from the console>";
    // Your digital human call agent ID.
    private static String Avatar_AGENT_ID = "<Your digital human call agent ID from the console>";
    // Your visual understanding call agent ID.
    private static String VISION_AGENT_ID = "<Your visual understanding call agent ID from the console>";
    
    // Configure the region.
    private static String Region = "cn-shanghai";
    Note

    The agent ID and region must match the settings in the console. If you want to test only one type of agent, you only need to configure the ID for that agent type.

    Region name

    Region ID

    China (Hangzhou)

    cn-hangzhou

    China (Shanghai)

    cn-shanghai

    China (Beijing)

    cn-beijing

    China (Shenzhen)

    cn-shenzhen

    Singapore

    ap-southeast-1

  4. After you configure the agent, use one of the following two methods to start the agent:

    • If you have deployed an AppServer: Open the AppServiceConst.java file and modify the server domain name.

      // AppServiceConst.java
      String HOST = "Your application server domain name";
    • If you have not deployed an AppServer: To quickly run the demo and test the agent, open the AUIAICallAuthTokenHelper.java file and configure the EnableDevelopToken parameter. Then, copy the App ID and App Key of your Alibaba Real-Time Communication (ARTC) application from the console to generate a startup authentication token within the application.

      Important

      This method requires you to enter your AppKey and other sensitive information into the local file. This method is suitable only for testing and development. Do not use this method in a production environment. This prevents security incidents that can occur if your AppKey is compromised.

      // AUIAICallAuthTokenHelper.java
      public class AUIAICallAuthTokenHelper {
          // Set to true to enable developer mode.
          private static final boolean EnableDevelopToken = true;
      
          // Copy the App ID of the ARTC application from the console.
          private static final String AICallRTCDevelopAppId = "The App ID of the ARTC application used by the agent";
          // Copy the App Key of the ARTC application from the console.
          private static final String AICallRTCDevelopAppKey = "The App Key of the ARTC application used by the agent";
      }

      To obtain the App ID and App Key for the ARTC application:

      1. Go to the AI Agents page in the IMS console. Click an agent to go to the agent details page.

        image

      2. Click ARTC application ID. You are redirected to the ApsaraVideo Live console, where the AppID and AppKey are provided.

        image

Quickly develop your own AI call feature

Follow these steps to quickly integrate AUIAICall into your application and enable the AI agent audio and video call feature.

Integrate the source code

  1. Import AUIAICall: After you download the source code from the repository, select File > New > Import Module from the Android Studio menu and import the AUIAICall and AUIBaseKits folders.

  2. Modify the third-party library dependencies in the build.gradle file.

    dependencies {
        implementation 'androidx.appcompat:appcompat:x.x.x'                     // Change x.x.x to a version that is compatible with your project.
        implementation 'com.google.android.material:material:x.x.x'             // Change x.x.x to a version that is compatible with your project.
        androidTestImplementation 'androidx.test.espresso:espresso-core:x.x.x'  // Change x.x.x to a version that is compatible with your project.
        implementation 'com.aliyun.aio:AliVCSDK_ARTC:x.x.x'                  // Change x.x.x to a version that is compatible with your project.
        implementation 'com.aliyun.auikits.android:ARTCAICallKit:x.x.x'
        implementation 'com.alivc.live.component:PluginAEC:2.0.0'
    }
    Note
    • The latest version of the ARTC software development kit (SDK) is 7.9.1.

    • The latest version of the AICallKit SDK is 2.9.1.

  3. Wait for the Gradle sync to complete. This finishes the source code integration.

Configure the source code

  • You have met the prerequisites.

  • Open the AppServiceConst.java file and modify the server domain name.

    // AppServiceConst.java
    String HOST = "Your application server domain name";
    Note

    If you have not deployed an AppServer, you can generate an authentication token within the application to quickly test the demo. For more information, see If you have not deployed an AppServer.

Call APIs

After you complete these steps, you can initiate AI calls from other modules or the homepage of your application using the component API. You can also modify the source code as needed.

/** Make sure that microphone and camera permissions are granted before you start. */
Context currentActivity = AUIAICallEntranceActivity.this;
Intent intent = new Intent(currentActivity, AUIAICallInCallActivity.class);

// Set the call type (voice, digital human, or visual understanding). The type must correspond to the AgentId type.
ARTCAICallEngine.ARTCAICallAgentType aiCallAgentType = 
    ARTCAICallEngine.ARTCAICallAgentType.VoiceAgent;
// The agent ID. It cannot be nil.
String aiAgentId = "";
// The region where the agent is located. It cannot be nil.
String aiAgentRegion = "";
// The ID of the user who joins the RTC call. We recommend that you use the logon user ID from your business.
String userId = "123";
// The call authentication token. For more information, see https://www.alibabacloud.com/help/en/ims/user-guide/generate-artc-authentication-token
String token = "";

intent.putExtra(AUIAIConstStrKey.BUNDLE_KEY_LOGIN_USER_ID, userId);
// Agent type
intent.putExtra(AUIAIConstStrKey.BUNDLE_KEY_AI_AGENT_TYPE, aiCallAgentType);
// Agent ID
intent.putExtra(AUIAIConstStrKey.BUNDLE_KEY_AI_AGENT_ID, aiAgentId);
// The region where the agent is located
intent.putExtra(AUIAIConstStrKey.BUNDLE_KEY_AI_AGENT_REGION, aiAgentRegion);
// Set the call authentication token
intent.putExtra(AUIAIConstStrKey.BUNDLE_KEY_RTC_AUTH_TOKEN, token);

currentActivity.startActivity(intent);
Note

For more information about how to generate an authentication token for calls, see Generate an ARTC authentication token.