Menu

Android

Last updated: 2023-09-12 10:51:34Download PDF
This document shows you how to quickly run TRTC-API-Example (Android).

Environment Requirements

Android 4.1 (SDK API level 16) or later; Android 5.0 (SDK API level 21) or later is recommended.
Android Studio 3.5 or later
Devices with Android 4.1 or later

Prerequisites

Directions

Step 1. Create an application

1. Log in to the TRTC console and select RTC Engine.
2. Click Start now and enter an application name such as APIExample. If you have already created an application, click link existing application.
3. Add or edit tags according to your actual business needs and click Create application.



Step 2. Get your SDKAppId and SecretKey

After your application created, you can get your SDKAppID and SecretKey on Basic informaction. SDKAppID and SecrentKey is needed for running demo.



Step 3. Download the SDK and demo source code

1. You can download the sample code for 【Android】platform on github.
2. The steps to import SDK can refer to 【Android SDK import】.
explain
The method for generating UserSig described in this document involves configuring SECRETKEY in the client code. In this method, SECRETKEY may be easily decompiled and reversed, and if your key is disclosed, attackers can steal your Tencent Cloud traffic. Therefore, this method is suitable only for the local execution and debugging of TRTC-API-Example.
The best practice is to integrate the calculation code of UserSig into your server and provide an application-oriented API. When UserSig is needed, your application can send a request to your server for a dynamic UserSig. For more information, see How do I calculate UserSig during production?.

Step 4. Configure demo project files

1.Find and open TRTC-API-Example/Debug/src/main/java/com/tencent/trtc/debug/GenerateTestUserSig.java.
2.Please Modify SDKAppID and SECRETKEY.
SDKAPPID: `0` by default. Set it to the actual `SDKAppID`.
SECRETKEY: left empty by default. Set it to the actual key.

Step 5. Compile and run the demo

Open the demo project TRTC-API-Example with Android Studio (v3.5 or later) and run the project.

FAQs

1. The app is running on two mobile phones, but why can't they display the images of each other?

Make sure that the two mobile phones use different UserID. With TRTC, you cannot use the same UserID on two devices simultaneously unless the SDKAppID is different.

2. What are the restrictions of the firewall?

The SDK uses the UDP protocol for audio/video transmission and therefore cannot be used in office networks that block UDP. If you encounter such a problem, you can refer to Firewall Restrictions to troubleshoot the issue.