AndroidDemo - aopacloud/aopa-rtc GitHub Wiki
Opa provides an open source sample project on GitHub AopaRtcAndroidDemonstrate the API usage examples of the OPA RTC SDK to help developers better understand and use the functions of the OPA SDK.
This article describes how to quickly run through Android sample projects and experience real-time audio and video functions.
-
Android Studio 4.2 and above.
-
Android API level 21 and above.
-
Two mobile devices running Android 5.0 and above.
take care
Opa recommends using real machine to run the project. Some simulators may have missing functions or performance problems.
-
A computer that can access the Internet. If you have deployed a firewall in your network environment, refer to [Coping with firewall restrictions] to use the Orpa service normally.
-
A valid Opa account and Opa project. Please refer to [Opening Service] to obtain the following information from the Opa console:
- App ID: A string randomly generated by Opa to identify your app.
- (Optional) App certificate: The App certificate provided by OPA is used to deploy and generate a token on the server or use the console to generate a temporary token.
-
Run the following command to clone the warehouse locally:
Shell
git clone [email protected]:aopacloud/aopa-rtc.git
-
The warehouse contains sample projects of all native platforms of the Opa RTC SDK, of which the API usage examples of the Android platform are located in the path of '/Android'.
Path Description /aopa-rtc/AopaRtcAndroid
API usage examples of the Opa * * Video * * SDK
information
This article takes the video sample project as an example. To run through the audio sample project, refer to the following steps to operate under the audio folder.
-
Integrate SDK and install dependencies
/AopaRtcAndroid/app/build.gradle
The integration SDK and the code required for installation dependency have been added to the file. The SDK will automatically complete the integration after synchronizing the gradle. -
Set App ID and App Certificate
Open the file '/AopaRtcAndroid/app/src/main/res/values/string config. xml', and fill in the 'YOUR APP ID' and 'YOUR APP CERTIFICATE' with the App ID and App Certificate you obtained from the VoIP console.
XML
<?xml version="1.0" encoding="utf-8"?> <resources> <!-- 奥帕 App ID --> <string name="aopa_app_id" translatable="false">YOUR APP ID</string> <!-- 奥帕 App 证书 注意:如果项目没有开启证书鉴权,这个字段留空。 --> <string name="aopa_app_certificate" translatable="false">YOUR APP CERTIFICATE</string> </resources>
-
Open the folder '/AopaApi Example/BanRtcAndroid' with Android Studio.
-
Open the Android device developer option, open USB debugging, connect the Android device to the computer through the USB cable, and check your Android device in the Android device option.
-
In Android Studio, click (Sync Project with Gradle Files) 进行 Gradle 同步。
-
After synchronization is successful, click (Run 'app') 开始编译。
-
After successful compilation, it will appear on your Android device! 图片 (Aopa API Example) 应用。
-
After opening the * * Aopa API Example * * application, you can choose any scenario you want to experience. Take * * Video Interactive Live * * as an example, enter the channel name (such as' test '), and click * * Add Channel * *.
-
To better experience various audio and video interaction scenarios, you can invite a friend to use another device to run the sample project (ensure that the App ID remains the same). Take * * Video interactive live broadcast * * as an example. After you enter the same channel name and join the channel, you will see each other and hear each other's voices.