- Documentation
- File Sharing
- Quick Starts
- Integration
Integration
1 Prerequisites
- ZegoDocsView SDK has been downloaded.
- Please go to ZEGO Management Console to register an account and apply for the AppID and AppSign required to initialize the SDK. Please refer to Project Management for the application process.
2 Prepare the Environment
- Android Studio 4.0 or above.
- Android version is at least 5.0 (recommended to use a real device).
- The Android device is connected to the Internet.
3 Integrated SDK
3.1 New Example Project
This step takes how to create a new project as an example. If it is integrated into an existing project, you can ignore this step.
Open
Android Studio
and select the menuFile
>New
>New Project
.Select the project type
Empty Activity
.Select the project storage path.
Click
Finish
to complete the new project creation.
3.2 Import SDK
ZegoDocsView SDK is built on AndroidX, so the imported project also needs to be built on AndroidX. If the developer’s project does not meet this requirement, please refer to Migrating to AndroidX for migration.
Unzip the downloaded
zegodocsview_android.zip
file to getzegodocsview.aar
and copy it to your project directory libs/ folder.Add the following code under the
dependencies
node in theapp/build.gradle
file:implementation fileTree(include: ['*.jar','*.aar'], dir:'libs')
The SDK depends on the following modules. Add the following code under the
dependencies
node in theapp/build.gradle
file:// recyclerview implementation "androidx.recyclerview:recyclerview:1.1.0" //The current latest version is 1.1.0 // SDK is developed using kotlin, if it is a pure java project, you need to add this dependency implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.4.21" //The latest version at the time of writing is 1.4.21 // Only ZegoDocsView SDK 1.16 version needs to add this dependency implementation "androidx.webkit:webkit:1.4.0" //The latest version is 1.4.0
Add a permission statement, open the
app/AndroidManifest.xml
file, and add the following content:<!-- Required permissions for SDK --> <uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
As Android 6.0 requires dynamic application of permissions on some of the more important permissions, you cannot just declare permissions through the AndroidMainfest.xml
file. Therefore, you need to refer to and execute the following code (requestPermissions is a method of Activity).
String[] permissionNeeded = {
"android.permission.WRITE_EXTERNAL_STORAGE",
"android.permission.READ_EXTERNAL_STORAGE"};
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (ContextCompat.checkSelfPermission(this, "android.permission.WRITE_EXTERNAL_STORAGE") != PackageManager.PERMISSION_GRANTED ||
ContextCompat.checkSelfPermission(this, "android.permission.READ_EXTERNAL_STORAGE") != PackageManager.PERMISSION_GRANTED) {
requestPermissions(permissionNeeded, 101);
}
}
Permission description form:
Permission | Necessity | Permission Description | Reason |
---|---|---|---|
INTERNET | Necessary permissions | Access to network permissions | The basic functions of the SDK can only be used when connected to the Internet |
WRITE_EXTERNAL_STORAGE | Necessary permissions | Built-in SDK write permissions | SDK will save logs and related configuration files in the built-in SDK |
READ_EXTERNAL_STORAGE | Necessary permissions | Built-in SDK read permissions | SDK needs to upload local files |
Prevent code confusion
In the proguard-rules.pro file, add the configuration of the -keep class to the SDK, so as to prevent the SDK public class names from being confused:
-keep class im.zego.zegodocs.**{*;}