# Android Integration
Integration Sample Code
We provide a DEMO project. Developers can obtain the integration sample code from Github (international) (opens new window) or Gitee (domestic) (opens new window).
# 1. Obtain Credentials
Please Note
To integrate the SDK, you must first create an application and bind a Mini-Program on the FinClip platform, and obtain the SDK KEY and SDK SECRET specific to each application. Then you can fill in the corresponding parameters when integrating the SDK. When a Mini-Program is opened, the SDK will automatically initialize and verify whether the SDK KEY, SDK SECRET, and BundleID (Application ID) are correct.
You can 【click here】 to see how to obtain the required SDK KEY and SDK SECRET. Please be sure to confirm that the parameters filled in during SDK integration are correct; otherwise, the Mini-Program will fail to open.
# 2. Import the SDK
# 2.1 Via Gradle Dependency
# 2.1.1 Content to Configure in the Project's build.gradle
Add the maven repository address in the project's build.gradle:
maven {
url "https://gradle.finogeeks.club/repository/applet/"
credentials {
username "applet"
password "123321"
}
}
Since part of the SDK code is written in Kotlin, you need to add the Kotlin gradle plugin in the project's build.gradle:
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.61"
The complete configuration of the project's build.gradle is as follows:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:3.5.2"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.61"
}
}
allprojects {
repositories {
google()
jcenter()
maven {
url "https://gradle.finogeeks.club/repository/applet/"
credentials {
username "applet"
password "123321"
}
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
# 2.1.2 Add the SDK Dependency in Gradle
Add the dependency on finapplet in the dependencies of the gradle file:
implementation 'com.finogeeks.lib:finapplet:x.y.z' // x.y.z must be replaced with the specific version number
Note
- The dynamic libraries in the SDK are hardened. Hardened dynamic libraries cannot be compressed during compilation and packaging; otherwise, an error will be reported when loading.
- Versions of finapplet before 2.42.5 (exclusive) depend on sdkcore (com.finogeeks.finochat.sdk:sdkcore).
- finapplet versions 2.42.5-2.43.3 depend on finclipcore (com.finogeeks.finclip.sdk:finclipcore).
- finapplet 2.43.5 (inclusive) and later versions depend on sdkcore (com.finogeeks.finclip.sdk:sdkcore).
Therefore, you need to add the doNotStrip configuration in the build.gradle under the App module :
packagingOptions {
// libsdkcore.so is hardened and cannot be compressed; otherwise, an error will be reported when loading the dynamic library
// For finapplet versions before 2.42.5 and after 2.43.3, use this
doNotStrip "*/x86/libsdkcore.so"
doNotStrip "*/x86_64/libsdkcore.so"
doNotStrip "*/armeabi/libsdkcore.so"
doNotStrip "*/armeabi-v7a/libsdkcore.so"
doNotStrip "*/arm64-v8a/libsdkcore.so"
// For finapplet versions 2.42.5--2.43.3, use this
//doNotStrip "*/x86/libfinclipcore.so"
//doNotStrip "*/x86_64/libfinclipcore.so"
//doNotStrip "*/armeabi/libfinclipcore.so"
//doNotStrip "*/armeabi-v7a/libfinclipcore.so"
//doNotStrip "*/arm64-v8a/libfinclipcore.so"
}
The complete configuration is as follows:
apply plugin: 'com.android.application'
android {
buildToolsVersion '28.0.3'
compileSdkVersion 28
defaultConfig {
applicationId "com.finogeeks.finappletdemo"
minSdkVersion 19
targetSdkVersion 28
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
// libsdkcore.so is hardened and cannot be compressed; otherwise, an error will be reported when loading the dynamic library
doNotStrip "*/x86/libsdkcore.so"
doNotStrip "*/x86_64/libsdkcore.so"
doNotStrip "*/armeabi/libsdkcore.so"
doNotStrip "*/armeabi-v7a/libsdkcore.so"
doNotStrip "*/arm64-v8a/libsdkcore.so"
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.finogeeks.lib:finapplet:x.y.z' // x.y.z must be replaced with the specific version number
}
# 2.2 Via aar Dependency
If you use Gradle dependency, you can skip this section.
Depending on aar files requires you to configure the dependencies of other third-party libraries yourself. The following explains the third-party libraries involved in each SDK.
# 2.2.1 FinclipCore / SdkCore
It does not depend on any third-party library, but you need to make settings adjustments according to different versions of finapplet.
Note:
- The dynamic libraries in the SDK are hardened. Hardened dynamic libraries cannot be compressed during compilation and packaging; otherwise, an error will be reported when loading.
- Versions of finapplet before 2.42.5 (exclusive) depend on sdkcore (com.finogeeks.finochat.sdk:sdkcore).
- finapplet versions 2.42.5-2.43.3 depend on finclipcore (com.finogeeks.finclip.sdk:finclipcore).
- finapplet 2.43.5 (inclusive) and later versions depend on sdkcore (com.finogeeks.finclip.sdk:sdkcore).
# 2.2.2 Core SDK (finapplet)
// Versions before 2.50.9 (exclusive)
// appcompat-v7
implementation "com.android.support:appcompat-v7:23.0.0"
// support-v4
implementation "com.android.support:support-v4:23.0.0"
// Recyclerview
implementation "com.android.support:recyclerview-v7:23.2.0"
// Versions after 2.50.9 (inclusive)
// appcompat
implementation "androidx.appcompat:appcompat:1.0.0"
// legacy-support-v4
implementation "androidx.legacy:legacy-support-v4:1.0.0"
// Recyclerview
implementation "androidx.recyclerview:recyclerview:1.0.0"
// Kotlin
implementation "org.jetbrains.kotlin:kotlin-stdlib:1.3.61"
// Gson
implementation "com.google.code.gson:gson:2.9.0"
// zxing
implementation "com.google.zxing:core:3.3.0"
// zxing android-core (required before Core SDK 2.41.1)
implementation "com.google.zxing:android-core:3.3.0"
// Choose 1 of the following 3 according to the version
// SdkCore (required before Core SDK 2.42.5 (exclusive))
implementation "com.finogeeks.finochat.sdk:sdkcore:x.y.z"
// FinclipCore (required for Core SDK 2.42.5-2.43.3)
implementation "com.finogeeks.finclip.sdk:finclipcore:x.y.z"
// New SdkCore (required from Core SDK 2.43.5 (inclusive))
implementation "com.finogeeks.finclip.sdk:sdkcore:x.y.z"
Note
x.y.z must be replaced with the version number indicated by the corresponding sdk file name in the extracted directory of the downloaded aar archive.
# 2.2.3 Extension SDK (plugins)
// finapplet
compileOnly "com.finogeeks.lib:finapplet:2.35.1"
// Kotlin
implementation "org.jetbrains.kotlin:kotlin-stdlib:1.3.61"
// beacon
implementation "org.altbeacon:android-beacon-library:2.13.1"
# 2.2.4 WebRTC SDK
// finapplet
compileOnly "com.finogeeks.lib:finapplet:2.35.1"
// Kotlin
implementation "org.jetbrains.kotlin:kotlin-stdlib:1.3.61"
// Recyclerview
implementation "com.android.support:recyclerview-v7:23.2.0"
// constraintlayout
implementation "com.android.support.constraint:constraint-layout:1.1.3"
// appcompat
implementation "com.android.support:appcompat-v7:23.0.0"
// WebRTC
implementation "org.webrtc:google-webrtc:1.0.32006"
# 2.2.5 Map SDK
// finapplet
compileOnly "com.finogeeks.lib:finapplet:2.35.1"
// Kotlin
implementation "org.jetbrains.kotlin:kotlin-stdlib:1.3.61"
// Versions before 2.50.9 (exclusive)
// support-v4
implementation "com.android.support:support-v4:26.1.0"
// Recyclerview
implementation "com.android.support:recyclerview-v7:26.1.0"
// Versions after 2.50.9 (inclusive)
// androidx
implementation "androidx.core:core:1.2.0"
// Recyclerview
implementation "androidx.recyclerview:recyclerview:1.2.0"
// AMap
compileOnly "com.amap.api:3dmap:8.0.0"
compileOnly "com.amap.api:location:5.5.1"
compileOnly "com.amap.api:search:7.9.0"
// gms
compileOnly "com.google.android.gms:play-services-location:16.0.0"
compileOnly "com.google.android.gms:play-services-maps:16.1.0"
// Baidu
compileOnly "com.baidu.lbsyun:BaiduMapSDK_Map:7.4.0"
compileOnly "com.baidu.lbsyun:BaiduMapSDK_Location:9.1.8"
compileOnly "com.baidu.lbsyun:BaiduMapSDK_Search:7.4.0"
# 2.2.6 Contact SDK
// finapplet
compileOnly "com.finogeeks.lib:finapplet:2.35.1"
// Kotlin
implementation "org.jetbrains.kotlin:kotlin-stdlib:1.3.61"
# 2.2.7 Clipboard SDK
// finapplet
compileOnly "com.finogeeks.lib:finapplet:2.35.1"
// Kotlin
implementation "org.jetbrains.kotlin:kotlin-stdlib:1.3.61"
# 2.2.8 Wechat SDK
// finapplet
compileOnly "com.finogeeks.lib:finapplet:2.35.1"
// Kotlin
implementation "org.jetbrains.kotlin:kotlin-stdlib:1.3.61"
// WeChat
implementation "com.tencent.mm.opensdk:wechat-sdk-android:6.8.0"
# 2.2.9 Media SDK
// finapplet
compileOnly "com.finogeeks.lib:finapplet:2.35.1"
// Kotlin
implementation "org.jetbrains.kotlin:kotlin-stdlib:1.3.61"
// ijk
compileOnly 'tv.danmaku.ijk.media:ijkplayer-java:0.8.8'
compileOnly 'tv.danmaku.ijk.media:ijkplayer-armv7a:0.8.8'
compileOnly 'tv.danmaku.ijk.media:ijkplayer-armv5:0.8.8'
compileOnly 'tv.danmaku.ijk.media:ijkplayer-arm64:0.8.8'
compileOnly 'tv.danmaku.ijk.media:ijkplayer-x86:0.8.8'
compileOnly 'tv.danmaku.ijk.media:ijkplayer-x86_64:0.8.8'
compileOnly 'tv.danmaku.ijk.media:ijkplayer-exo:0.8.8'
# 2.2.10 Share SDK
// Versions before 2.50.9 (exclusive)
// cardview
implementation "com.android.support:cardview-v7:23.0.0"
// Versions after 2.50.9 (inclusive)
// cardview
implementation "androidx.cardview:cardview:1.0.0"
// finapplet
compileOnly "com.finogeeks.lib:finapplet:2.35.1"
// Kotlin
implementation "org.jetbrains.kotlin:kotlin-stdlib:1.3.61"
// QrCode
implementation "cn.bingoogolapple:bga-qrcode-zxing:1.3.7"
// WeChat
compileOnly "com.tencent.mm.opensdk:wechat-sdk-android:6.8.0"
// Coroutines
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.9"
# 2.2.11 Cast SDK
// finapplet
compileOnly "com.finogeeks.lib:finapplet:2.35.1"
// Kotlin
implementation "org.jetbrains.kotlin:kotlin-stdlib:1.3.61"
// Cling library required
implementation "org.fourthline.cling:cling-core:2.1.1"
implementation "org.fourthline.cling:cling-support:2.1.1"
// Logger
implementation "com.orhanobut:logger:2.2.0"
implementation "org.eclipse.jetty:jetty-server:8.1.21.v20160908"
implementation "org.eclipse.jetty:jetty-servlet:8.1.21.v20160908"
implementation "org.eclipse.jetty:jetty-client:8.1.21.v20160908"
implementation "org.nanohttpd:nanohttpd:2.3.1"
# 2.2.12 Live SDK
// finapplet
compileOnly "com.finogeeks.lib:finapplet:2.35.1"
// Kotlin
implementation "org.jetbrains.kotlin:kotlin-stdlib:1.3.61"
# 2.2.13 XLog SDK
// finapplet
compileOnly "com.finogeeks.lib:finapplet:2.35.1"
// Kotlin
implementation "org.jetbrains.kotlin:kotlin-stdlib:1.3.61"
# 2.2.14 Calendar SDK
// finapplet
compileOnly "com.finogeeks.lib:finapplet:2.35.1"
// Kotlin
implementation "org.jetbrains.kotlin:kotlin-stdlib:1.3.61"
# 2.2.15 Dependency Description
- The Core SDK depends on SDK Core;
- All other SDKs depend on the Core SDK, and there are no mutual dependencies among them;
- The third-party libraries depended on via
compileOnlyin each SDK are optional dependencies (except for the Core SDK). If you want to use the capabilities provided by a third-party library, you need to depend on the corresponding library yourself.
# 2.3 Configuring Obfuscation Rules
After integrating the SDK, to prevent some code in the SDK that must not be obfuscated from being obfuscated, you need to add the following configuration to the project's obfuscation rules configuration file:
-keep class com.finogeeks.** {*;}
# 2.4 Sensitive Permissions Involved in the SDK
If you integrate all SDKs, the sensitive permissions involved include: storage, camera, audio recording, reading phone state, location, Bluetooth, and contacts. These permissions are basically triggered only when the corresponding APIs and components are called.
| Permission | Permission Name |
|---|---|
| Storage read | READ_EXTERNAL_STORAGE |
| Storage write | WRITE_EXTERNAL_STORAGE |
| Camera | CAMERA |
| Audio recording | RECORD_AUDIO |
| Read phone state | READ_PHONE_STATE (not required since 2.45.13) |
| Location | LOCATION |
| Bluetooth | BLUETOOTH |
The permissions involved in each SDK are as follows:
Sensitive permissions involved in the Core SDK (finapplet):
| Permission | Related APIs, Components |
|---|---|
| Storage read/write | chooseImage, chooseVideo, chooseMedia, saveImageToPhotosAlbum, saveVideoToPhotosAlbum, Video component screenshot, MediaViewer save image, MediaViewer save video, WebView component download file, WebView component file picker |
| Camera | scanCode, Camera component related APIs, chooseImage, chooseVideo, chooseMedia, WebView component file picker |
| Audio recording | Camera component, chooseVideo, chooseMedia |
| Get phone information | getSuperviseInfo (not required since 2.45.13) |
Sensitive permissions involved in the Extension SDK (mop_plugins):
| Permission | Related APIs, Components |
|---|---|
| Get location information | getLocation |
| Audio recording | startRecord, recorderManager |
Sensitive permissions involved in MapSDK (mapsdk):
| Permission | Related APIs, Components |
|---|---|
| Get location information | chooseLocation, getLocation, openLocation, choosePoi, Map component |
Sensitive permissions involved in Bluetooth SDK (bluetooth):
| Permission | Related APIs, Components |
|---|---|
| Bluetooth | openBluetoothAdapter, startBeaconDiscovery, startBluetoothDevicesDiscovery, createBLEConnection, createBLEPeripheralServer, startBLEPeripheralAdvertising |
| Location | startBeaconDiscovery, startBluetoothDevicesDiscovery |
Sensitive permissions involved in Agora SDK (agora):
| Permission | Related APIs, Components |
|---|---|
| Audio recording | live-pusher, live-player components |
| Camera | live-pusher, live-player components |
Sensitive permissions involved in WebRTCSDK (webrtc):
| Permission | Related APIs, Components |
|---|---|
| Camera | webrtc-video component |
| Audio recording | webrtc-video component |
# 3. SDK Initialization
We strongly recommend initializing the SDK in Application. The parameters required for SDK initialization are as follows (SDK initialization only needs to be called once; avoid repeated calls):
# 3.1 Configuration Information for the Mini-Program Framework
Starting from version 2.13.102, configuring multiple server information is supported, allowing Mini-Programs in different environments to be opened simultaneously. The configuration parameters are as follows:
// Collection of server information
List<FinStoreConfig> storeConfigs = new ArrayList<>();
// Information for server 1
FinStoreConfig storeConfig1 = new FinStoreConfig(
"SDK Key information", // SDK Key
"SDK Secret information", // SDK Secret
"Address of server 1", // Server address
"Data reporting server address of server 1", // Data reporting server address
"/api/v1/mop/", // Server API request route prefix
"",
"Encryption method" // Encryption method, Chinese national standard: SM, md5: MD5 (recommended)
);
storeConfigs.add(storeConfig1);
// Information for server 2
FinStoreConfig storeConfig2 = new FinStoreConfig(
"SDK Key information", // SDK Key
"SDK Secret information", // SDK Secret
"Address of server 2", // Server address
"Data reporting server address of server 2", // Data reporting server address
"/api/v1/mop/", // Server API request route prefix
"",
"Encryption method" // Encryption method, Chinese national standard: SM, md5: MD5 (recommended)
);
storeConfigs.add(storeConfig2);
FinAppConfig config = new FinAppConfig.Builder()
.setFinStoreConfigs(storeConfigs) // Collection of server information
.build();
# 3.2 Setting the SDK Initialization Status Callback
Implement the FinCallback interface to listen for the SDK initialization status:
// SDK initialization result callback, used to receive the SDK initialization status
FinCallback<Object> callback = new FinCallback<Object>() {
@Override
public void onSuccess(Object result) {
// SDK initialization succeeded
}
@Override
public void onError(int code, String error) {
// SDK initialization failed
Toast.makeText(AppletApplication.this, "SDK initialization failed", Toast.LENGTH_SHORT).show();
}
@Override
public void onProgress(int status, String error) {
}
};
# 3.3 Initializing the SDK
Call the initialization API to initialize the SDK:
FinAppClient.INSTANCE.init(this, config, callback);
# 3.4 Multi-Process Handling for SDK Initialization
The SDK is implemented using a multi-process mechanism. Each Mini-Program runs in an independent process, i.e., one Mini-Program corresponds to one process. When initializing the SDK, one point requires special attention: when the Mini-Program process is created, no initialization operations need to be performed, not even the initialization of the Mini-Program SDK should be executed in the Mini-Program process.
For example, if the application uses some third-party libraries that need to be initialized when the application starts, then when performing initialization in the Application, these third-party libraries only need to be initialized when the current process is the Host-App process. The Mini-Program process does not need to initialize these libraries.
Therefore, before initializing the SDK, you must determine which process the current process is. If it is the Mini-Program process, do not perform any operations:
if (FinAppClient.INSTANCE.isFinAppProcess(this)) {
return;
}
The above is the entire process for initializing the SDK. The complete code is as follows:
package com.example.finogeeks.appletdemo;
import android.os.Process;
import android.support.multidex.MultiDexApplication;
import android.text.TextUtils;
import android.widget.Toast;
import com.example.finogeeks.appletdemo.api.ApiOpenPage;
import com.example.finogeeks.appletdemo.api.ApiOpenPageForResult;
import com.example.finogeeks.appletdemo.api.DrawModule;
import com.example.finogeeks.appletdemo.util.ProcessUtilKt;
import com.finogeeks.lib.applet.client.FinAppClient;
import com.finogeeks.lib.applet.client.FinAppConfig;
import com.finogeeks.lib.applet.interfaces.FinCallback;
/**
* The application's {@link android.app.Application}
*/
public class AppletApplication extends MultiDexApplication {
@Override
public void onCreate() {
super.onCreate();
if (FinAppClient.INSTANCE.isFinAppProcess(this)) {
// The Mini-Program process does not perform any initialization operations
return;
}
// Server information collection
List<FinStoreConfig> storeConfigs = new ArrayList<>();
// Information for server 1
FinStoreConfig storeConfig1 = new FinStoreConfig(
"SDK Key information", // SDK Key
"SDK Secret information", // SDK Secret
"Address of server 1", // Server address
"Data reporting server address of server 1", // Data reporting server address
"/api/v1/mop/", // Server API request route prefix
"",
"Encryption method", // Encryption method, Chinese national standard: SM, md5: MD5 (recommended)
false
);
storeConfigs.add(storeConfig1);
// Information for server 2
FinStoreConfig storeConfig2 = new FinStoreConfig(
"SDK Key information", // SDK Key
"SDK Secret information", // SDK Secret
"Address of server 2", // Server address
"Data reporting server address of server 2", // Data reporting server address
"/api/v1/mop/", // Server API request route prefix
"",
"Encryption method", // Encryption method, Chinese national standard: SM, md5: MD5 (recommended)
false
);
storeConfigs.add(storeConfig2);
FinAppConfig config = new FinAppConfig.Builder()
.setFinStoreConfigs(storeConfigs) // Server information collection
.build();
FinAppClient.INSTANCE.init(this, config, new FinCallback<Object>() {
@Override
public void onSuccess(Object result) {
}
@Override
public void onError(int code, String error) {
Toast.makeText(AppletApplication.this, "SDK initialization failed", Toast.LENGTH_SHORT).show();
}
@Override
public void onProgress(int status, String error) {
}
});
}
}
# 3.5 Using TBS X5 WebView
Note for overseas users:
To reduce the size increment of your apk package, the TBS SDK adopts a solution of dynamically delivering the kernel in the background. Since Google Play prohibits the delivery of any binary code (including so, dex, jar) and the use of pluginization technology, apps using the X5 kernel are not supported for listing on overseas Google Play.
By default, the SDK uses the system WebView to load Mini-Programs, and it also supports using TBS X5 WebView to load Mini-Programs. Using the TBS X5 kernel can achieve same-layer rendering of some Native Components. Currently, the Native Components that support same-layer rendering through the TBS X5 kernel are:
- video
- live-player
- live-pusher
- map
- canvas
- input
- textarea
How to enable TBS X5 WebView:
Depend on the TBS SDK in the APP project, as follows:
implementation 'com.tencent.tbs:tbssdk:44275' // It is recommended to use a relatively new version
After depending on the TBS SDK, the WebView used internally by the SDK will automatically switch to X5 WebView. During SDK initialization, the TBS SDK will be initialized. After the X5 kernel is successfully loaded, various capabilities provided by the X5 kernel can be used.
Because Tencent's delivery of X5 kernel files may be affected by network conditions, which may cause slow or failed X5 kernel downloads, the SDK also supports downloading X5 kernel files from your own server. The implementation is as follows:
Download the TBS X5 kernel file:
Download address for the armeabi architecture X5 kernel file (opens new window)
Download address for the arm64-v8a architecture X5 kernel file (opens new window)
Upload the downloaded X5 kernel file to your own server, and rename the kernel file after uploading it to the server:
Rename the armeabi architecture X5 kernel file to: armeabi_release.tbs
Rename the arm64-v8a architecture X5 kernel file to: arm64-v8a_release.tbs
The renaming is to facilitate the SDK internally concatenating the complete kernel file download address.
Set the SDK initialization configuration parameters:
FinAppConfig finAppConfig = new FinAppConfig.Builder() // Whether to load the TBS X5 kernel locally, needs to be set to true .setUseLocalTbsCore(true) // The server address for downloading the TBS X5 kernel file // Note: // 1. Must be replaced with your own server address // 2. The address here is not the complete server file address // Internally, the SDK will use the address configured here, combined with the phone's CPU architecture type, // and continue to concatenate the corresponding X5 kernel file name afterward, thereby forming the complete address // Complete address example: // https://xxx.yyy.zzz/sdk/x5/latest/armeabi_release.tbs // https://xxx.yyy.zzz/sdk/x5/latest/arm64-v8a_release.tbs .setTbsCoreUrl("https://xxx.yyy.zzz/sdk/x5/latest/") .build();
After the above steps, the SDK can download the X5 kernel file from your own server during initialization.
# 3.6 Using the WebView Hole-Punching Solution to Implement Same-Layer Rendering
Supported after version 2.43.7 (including 2.43.7)
A new lightweight same-layer rendering solution has been added, which implements same-layer rendering by punching holes in the WebView. The supported Native Components are:
- live-player
- live-pusher
- video (supported starting from version 2.45.7)
- This solution does not require the introduction of X5 or other third-party libraries. It is supported directly by using the finapple library.
implementation 'com.finogeeks.lib:finapplet:2.43.7' // x.y.z must be replaced with the specific version number, minimum 2.43.7
- Set the SDK initialization configuration parameters:
FinAppConfig finAppConfig = new FinAppConfig.Builder()
// Other configuration settings
// Needs to be set to true. This setting has the highest priority.
// Its priority is higher than X5 same-layer rendering. Once enabled, X5 will not be used, even if X5 is configured.
// In addition, due to the implementation principle, Video's controls need to be implemented by yourself, hiding the native controls. At the underlying level, it is impossible to interact with the native controls.
.setEnableHoleRender(true)
.build();
Notes: Implementation principle: Place the View corresponding to the Native Component at the bottom layer of the WebView, and then set the WebView's background to transparent. This simulates same-layer rendering (the native View will not cover the HTML elements on the WebView).
This solution is relatively lightweight and only supports components in fixed positions or full-screen situations; if the page scrolls, the Native Component will not scroll with the scroll position;
Internally, the Framework will set the background of the parent element of supported components to transparent (if it is not transparent, the underlying native View will be covered and invisible; see the implementation principle);
If you want to place elements above the component, please use HTML elements and do not use cover-view anymore;
# 4. SDK Usage Examples
# 4.1 Starting a Mini-Program
After publishing a Mini-Program on the platform, we can open the Mini-Program by calling the SDK interface for starting a Mini-Program. The code for starting a Mini-Program is as follows:
// Build request
RemoteFinAppletRequest request = new RemoteFinAppletRequest(apiServer, appId);
// Or use the following method to omit the server environment address configuration; by default, the first server environment address configured during SDK initialization will be used
RemoteFinAppletRequest request = IFinAppletRequest.Companion.fromAppId(appId);
// Open the Mini-Program
FinAppClient.INSTANCE.getAppletApiManager().startApplet(context, request, callback);
If startup parameters need to be carried when starting the Mini-Program, you can call the interface that supports passing startup parameters, as follows:
Map<String, String> params = new HashMap<>();
// path is the Mini-Program page path
params.put("path", "/pages/index/index");
// query is the startup parameter, in the form of "key1=value1&key2=value2 ..."
params.put("query", "aaa=test&bbb=123");
// Configure parameters for the request
request.setStartParams(params);
FinAppClient.INSTANCE.getAppletApiManager().startApplet(context, request, callback);
# 4.2 Custom Mini-Program APIs
To implement custom Mini-Program APIs, you need to create a class that inherits from AbsApi, and override the parent class methods in the created subclass (the most important are the apis() method and the invoke() method).
The following uses opening a native page inside a Mini-Program as an example to demonstrate how to implement and register a custom Mini-Program API:
- First, create the
ApiOpenPageclass, inheriting fromAbsApi; - Then, override the
apis()method inApiOpenPageto return the names of all callable APIs. We can add multiple API names to the array returned byapis(). The current example only adds oneopenPage; - Finally, override the
invoke()method inApiOpenPageto implement the corresponding logic. The current example implements a simple page jump, that is, if theopenPageinterface is called in the Mini-Program, an Activity will be started on the native side.
package com.example.finogeeks.appletdemo.api;
import android.content.Context;
import android.content.Intent;
import android.text.TextUtils;
import com.example.finogeeks.appletdemo.SecondActivity;
import com.finogeeks.lib.applet.api.AbsApi;
import com.finogeeks.lib.applet.interfaces.ICallback;
import org.json.JSONObject;
/**
* Custom Mini-Program API, implementing a simple page jump function
*/
public class ApiOpenPage extends AbsApi {
private Context mContext;
public ApiOpenPage(Context context) {
mContext = context;
}
/**
* Return an array of callable API names
*
* @return An array of callable API names
*/
@Override
public String[] apis() {
return new String[]{"openPage"};
}
/**
* When the corresponding API call is received, this method will be triggered. Implement the API business logic in this method
*
* @param event Event name, i.e. API name
* @param param Event parameters
* @param callback Callback interface, used to return the result to the Mini-Program after executing the business logic
*/
@Override
public void invoke(String event, JSONObject param, ICallback callback) {
if ("openPage".equals(event)) {
String url = param.optString("url");
if (!TextUtils.isEmpty(url)) {
Intent intent = new Intent();
intent.setClass(mContext, SecondActivity.class);
mContext.startActivity(intent);
callback.onSuccess(null);
} else {
callback.onFail();
}
}
}
}
After implementing the custom Mini-Program API, two steps are still required before the API can be called in the Mini-Program:
- Register the custom Mini-Program API with the SDK. Implement API registration by calling the
registerApimethod of theIExtensionApiManagerinterface:
FinAppClient.INSTANCE.getExtensionApiManager().registerApi(new ApiOpenPage(context));
- Add the custom API configuration in the Mini-Program project. Create a
FinClipConf.jsfile in the root directory of the Mini-Program project, and configure the corresponding custom API inFinClipConf.jsas follows:
module.exports = {
extApi:[
{
name: 'openPage', // Extended API name
params: { // Extended API parameters; only required parameters need to be listed
url: ''
}
}
]
}
# 4.3 Interaction Between Native Code and Mini-Program Web Pages
When a Mini-Program loads a web page, if the web page needs to call native functionality, the native code must be registered with the SDK in the form of a custom JSSDK API. The implementation of a custom JSSDK API is the same as that of a custom Mini-Program API, i.e., inherit from AbsApi and override the parent class methods.
The difference is that during API registration, the registerApi method of IExtensionWebApiManager is called instead of the method in IExtensionApiManager:
FinAppClient.INSTANCE.getExtensionWebApiManager().registerApi(new WebApi(context));
In addition, the SDK also supports native code calling JavaScript code in web pages as follows:
FinAppClient.INSTANCE.getAppletApiManager().callJS("appId", "funcName", "funParams", 1)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(
result -> Toast.makeText(context, "callJS successfully : " + result, Toast.LENGTH_SHORT).show(),
throwable -> Toast.makeText(context, "callJS failed : " + throwable.getLocalizedMessage(), Toast.LENGTH_SHORT).show()
);
# 5. Extension SDK
The above content is all explained around the core SDK finapplet. In fact, in addition to the core SDK, we also provide an Extension SDK. The Extension SDK is a library that depends on the core SDK and provides various Mini-Program APIs that are not available in the core SDK.
The reason for providing the Extension SDK is to ensure that the core SDK remains lightweight while also ensuring that the Mini-Program APIs are sufficiently rich. The core SDK is responsible for establishing the basic framework for running Mini-Programs and providing a small portion of the most essential APIs. In terms of permissions, it retains only basic permissions such as storage, camera, and geolocation, and its size is just over 1 MB. The Extension SDK exists as a supplement to the core SDK, and its APIs will continue to be enriched and improved.
Obtaining the Extension SDK
You can log in to the Resource Download Center (opens new window) to download the Android SDK file. The Extension SDK is also included in the downloaded archive.
If you want to use the APIs in the Extension SDK, simply add the Extension SDK library as a dependency in Gradle:
implementation 'com.finogeeks.mop:plugins:x.y.z' //x.y.z must be replaced with the specific version number
# 6. MapSDK
MapSDK supports the Map Component and location APIs.
It depends on the core SDK and serves as a supplement to the Map and Location features.
The map and positioning capabilities it provides depend on third-party map and positioning SDKs. It supports four combinations: AMap|AMap Location, Baidu Map|Baidu Location, Tencent Map|Tencent Location, and Google Maps|Google Location.
Note
- For the support of location APIs by the AMap, Baidu, Tencent, and Google solutions, please refer to "Development-API-Location".
- The AMap SDK allows an app to have at most 10 map view objects at the same time. When there are more than 10 map view objects, new map content will be displayed as a black screen. Therefore, when using AMap to implement the map component (i.e., depending on the AMap Extension SDK), the Mini-Program needs to remove and destroy the map in the page's onHide() and then create the map and add map content in onShow().
# 6.1 Integration
- Add the MapSDK library as a dependency in Gradle:
implementation 'com.finogeeks.mop:map:x.y.z' // x.y.z must be replaced with the specific version number
- Since the map and positioning capabilities implemented by MapSDK depend on third-party map and positioning SDKs, the Host-App also needs to integrate the third-party map and positioning SDKs and complete API_KEY, Service registration, etc.
Note
Please choose one of the following third-party SDK providers for integration.
For detailed integration instructions for third-party SDKs, please refer to the official integration documentation of the third-party SDK.
Depend on the third-party SDK library: (choose one)
// AMap (it is recommended not to use a version lower than the following, otherwise class/method errors may occur)
implementation 'com.amap.api:3dmap:8.0.0' // You can replace this with the version number you need
implementation 'com.amap.api:location:5.5.1' // You can replace this with the version number you need
implementation 'com.amap.api:search:7.9.0' // You can replace this with the version number you need
// Baidu (it is recommended not to use a version lower than the following, otherwise class/method errors may occur)
implementation 'com.baidu.lbsyun:BaiduMapSDK_Map:7.4.0' // You can replace this with the version number you need
implementation 'com.baidu.lbsyun:BaiduMapSDK_Location:9.1.8' // You can replace this with the version number you need
implementation 'com.baidu.lbsyun:BaiduMapSDK_Search:7.4.0' // You can replace this with the version number you need
// Tencent (it is recommended not to use a version lower than the following, otherwise class/method errors may occur)
implementation 'com.tencent.map:tencent-map-vector-sdk:5.1.0' // You can replace this with the version number you need
implementation 'com.tencent.map.geolocation:TencentLocationSdk-openplatform:7.5.2' // You can replace this with the version number you need
// Google
implementation 'com.google.android.gms:play-services-maps:16.1.0' // You can replace this with the version number you need (this version is recommended; versions above this are not supported)
implementation 'com.google.android.gms:play-services-location:16.0.0' // You can replace this with the version number you need (this version is recommended; versions above this are not supported)
Register the third-party SDK's API_KEY and Service in AndroidManifest.xml: (choose one according to the third-party SDK you depend on)
// AMap
<meta-data
android:name="com.amap.api.v2.apikey"
android:value="The ApiKey you applied for" />
<service android:name="com.amap.api.location.APSService" />
// Baidu
<meta-data
android:name="com.baidu.lbsapi.API_KEY"
android:value="The ApiKey you applied for" />
<service
android:name="com.baidu.location.f"
android:enabled="true"
android:process=":remote" />
// Tencent
<meta-data
android:name="TencentMapSDK"
android:value="The ApiKey you applied for" />
// Google
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="The ApiKey you applied for" />
Configure the SO library architectures supported by the third-party SDK in build.gradle:
android {
defaultConfig {
ndk {
// Set the supported SO library architectures (you can choose one or more platforms' so as needed)
abiFilters "armeabi", "armeabi-v7a", "arm64-v8a", "x86","x86_64"
}
}
}
# 6.2 Configuration
- Set the privacy policy (optional):
AMap, Baidu, and Tencent related SDKs require consent to the privacy policy in versions above a specific version before their features can be used normally.
For specific versions, please refer to the comments of the setting interface methods.
The interface definitions are as follows:
public class MapSDKInitializer {
/**
* Set the AMap privacy policy.
* Added since AMap SDK v8.1.0.
*
* @param isContains Whether the privacy policy contains the AMap Open Platform privacy policy. true means it contains it
* @param isShow Whether the privacy policy is displayed to the user in a pop-up. true means it is displayed
* @param isAgree Whether the privacy policy is agreed to
*/
public static void setAMapPrivacy(Context context, boolean isContains, boolean isShow, boolean isAgree)
/**
* Set the AMap Location privacy policy.
* Added since AMap Location SDK v5.6.0.
*
* @param isContains Whether the privacy policy contains the AMap Open Platform privacy policy. true means it contains it
* @param isShow Whether the privacy policy is displayed to the user in a pop-up. true means it is displayed
* @param isAgree Whether the privacy policy is agreed to
*/
public static void setAMapLocationPrivacy(Context context, boolean isContains, boolean isShow, boolean isAgree)
/**
* Set the Baidu Map privacy policy.
* Added since Baidu Map SDK v7.5.0.
*
* @param isAgree Whether the privacy policy is agreed to
*/
public static void setBaiduMapAgreePrivacy(Context context, boolean isAgree)
/**
* Set the Baidu Location privacy policy.
* Added since Baidu Location SDK v9.2.9.
*
* @param isAgree Whether the privacy policy is agreed to
*/
public static void setBaiduLocationAgreePrivacy(Context context, boolean isAgree)
/**
* Set the Tencent Map privacy policy.
* Added since Tencent Map SDK v4.5.6.
*
* @param isAgree Whether the privacy policy is agreed to
*/
public static void setTencentMapAgreePrivacy(Context context, Boolean isAgree)
/**
* Set the Tencent Location privacy policy.
* Added since Tencent Location v7.4.6.
*
* @param isAgree Whether the privacy policy is agreed to
*/
public static void setTencentLocationAgreePrivacy(Context context, Boolean isAgree)
}
- Set the Tencent Map secretKey (optional):
The interface definition is as follows:
public class MapSDKInitializer {
/**
* Set the Tencent Map WebService API secretKey.
* Used for chooseLocation and choosePoi POI search APIs.
*
* @param secretKey The encrypted string. If no secretKey is needed, there is no need to call this method, or pass null for secretKey
*/
public static void setTencentSecretKey(Context context, String secretKey)
}
- Set the Baidu Map coordinate system (optional):
Baidu Map allows setting the map coordinate system to BD09LL or GCJ02.
The interface definition is as follows:
public class MapSDKInitializer {
public enum CoordType {
GCJ02,
BD09LL
}
/**
* Set the Baidu Map coordinate system.
* Added since Baidu Map SDK 4.3.0.
*
* @param coordType Coordinate system type. BD09LL or GCJ02
*/
public static void setBaiduMapCoordType(Context context, CoordType coordType)
}
- Set the map type used by the Map Component and location-related APIs (optional):
The interface definition is as follows:
public class MapSDKInitializer {
/**
* The map type to use
*/
public enum UsingMap {
/**
* Auto. Automatically selected based on the integrated map and positioning SDK. Default value.
* When multiple types of map and positioning SDKs are integrated at the same time, the priority order is AMap -> Baidu -> Tencent -> Google.
*/
AUTO,
/**
* AMap
*/
AMAP,
/**
* Baidu
*/
BAIDU,
/**
* Tencent
*/
TENCENT,
/**
* Google
*/
GOOGLE
}
/**
* Set the map type used by the Map Component and location-related APIs.
* <p>
* When the APP integrates multiple types of map and positioning SDKs at the same time, this method can be used to set the specified map and positioning SDK to implement the Map Component and location-related API features.
* When the APP integrates only one type of map and positioning SDK, there is no need to call this method.
*
* @param usingMap The specified map type to use
*/
public static void setUsingMap(Context context, UsingMap usingMap)
}
# 7. Bluetooth SDK
To use Bluetooth APIs, you need to integrate the Bluetooth SDK separately. Once integrated, the APIs will take effect without additional configuration.
Integration method:
implementation 'com.finogeeks.mop:bluetooth:x.y.z'
# 8. Agora SDK
To use Agora-related APIs, you need to integrate the Agora SDK separately. Once integrated, the APIs will take effect without additional configuration.
Integration method:
implementation 'com.finogeeks.mop:agora:x.y.z'
If you integrate the Agora SDK by importing an aar, you need to add the Agora dependency additionally:
implementation 'io.agora.rtc:full-sdk:3.5.0'
# 9. WebRTC SDK
To use WebRTC-related APIs, you need to integrate the WebRTC SDK separately. Once integrated, the APIs will take effect without additional configuration.
Integration method:
implementation 'com.finogeeks.mop:webrtc:x.y.z'
If you integrate the WebRTC SDK by importing an aar, you need to add the WebRTC dependency additionally:
implementation 'org.webrtc:google-webrtc:1.0.32006'
# 10. Contact SDK
To use contact-related APIs, you need to integrate the Contact SDK separately. Once integrated, the APIs will take effect without additional configuration.
Integration method:
implementation 'com.finogeeks.mop:contact:x.y.z'
# 11. Clipboard SDK
To use clipboard-related APIs, you need to integrate the Clipboard SDK separately. Once integrated, the APIs will take effect without additional configuration.
Integration method:
implementation 'com.finogeeks.mop:clipboard:x.y.z'
# 12. WeChat SDK
A quick integration of the WeChat SDK, providing the ability to launch WeChat to obtain login, user information, phone number, and payment capabilities through WeChat Mini-Programs.
Please Note
To integrate the WeChat SDK, you must first apply for an AppID on the WeChat Open Platform. The AppID filled in here is the AppID under the Mobile Application, which generally starts with wx. Note that it is NOT the AppID of a WeChat Mini-Program, nor the original ID of a WeChat Mini-Program (starting with gh). These IDs are easily confused.
Integration method:
implementation 'com.finogeeks.mop:wechat:x.y.z'
And add the Mobile Application AppID you applied for on the WeChat Open Platform in the project's build.gradle file (e.g., app/build.gradle):
android {
// ..other configuration omitted
defaultConfig {
// ..other configuration omitted
resValue "string", "wechat_sdk_app_id", "Your AppID under the WeChat Open Platform Mobile Application"
}
}
Note
When using the WeChat SDK, ensure that its version matches the version of the core SDK you are currently using, and that it is 2.37.13 or above.
Note
Since the WeChat SDK needs to override the open-type related methods in IAppletHandler, specifically the six methods chooseAvatar, contact, feedback, getPhoneNumber, launchApp, and shareAppMessage.
Therefore, if you have implemented IAppletHandler and implemented the above six methods, the WeChat SDK will take over getPhoneNumber. Please migrate the remaining five methods as follows. If you have not implemented IAppletHandler or do not use the above six methods, you can ignore this.
Implement the
IWeChatOpenTypeHandlerinterface:class MyWeChatAppletOpenTypeHandler : IWeChatOpenTypeHandler { override fun chooseAvatar(callback: IAppletHandler.IAppletCallback) { // Your implementation logic } override fun contact(json: JSONObject): Boolean { // Your implementation logic } override fun feedback(bundle: Bundle): Boolean { // Your implementation logic } override fun launchApp(appParameter: String?): Boolean { // Your implementation logic } override fun shareAppMessage( appInfo: String, bitmap: Bitmap?, callback: IAppletHandler.IAppletCallback ) { // Your implementation logic } }After the core SDK is initialized successfully, set your implementation class. (Note that, like the core SDK, make sure to set it in the main process):
WeChatOpenTypeClient.instance.iWeChatOpenTypeHandler = MyWeChatAppletOpenTypeHandler()
Note
To avoid conflicts with WeChat OpenSDK-related callback classes, starting from version 2.39.11, the WeChat SDK no longer automatically generates the WeChat callback receiver class WXEntryActivity. Please refer to the official WeChat documentation Android Integration Guide (opens new window) to create WXEntryActivity yourself and add the WeChat SDK callback handling methods. Example as follows:
class WXEntryActivity : Activity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
FinWeChatWXEntry.handleWeChatIntent(this, intent)
// Your other business logic
finish()
}
override fun onNewIntent(intent: Intent?) {
super.onNewIntent(intent)
setIntent(intent)
FinWeChatWXEntry.handleWeChatIntent(this, intent)
// Your other business logic
finish()
}
}
# 13. Media SDK
Supported after version 2.38.0
The progressive playback (download-while-playing) of the video component requires integrating this SDK.
Integration method:
android {
packagingOptions {
doNotStrip "*/arm64-v8a/libijkffmpeg.so"
doNotStrip "*/arm64-v8a/libijkplayer.so"
doNotStrip "*/arm64-v8a/libijksdl.so"
doNotStrip "*/armeabi/libijkffmpeg.so"
doNotStrip "*/armeabi/libijkplayer.so"
doNotStrip "*/armeabi/libijksdl.so"
doNotStrip "*/armeabi-v7a/libijkffmpeg.so"
doNotStrip "*/armeabi-v7a/libijkplayer.so"
doNotStrip "*/armeabi-v7a/libijksdl.so"
doNotStrip "*/x86/libijkffmpeg.so"
doNotStrip "*/x86/libijkplayer.so"
doNotStrip "*/x86/libijksdl.so"
doNotStrip "*/x86_64/libijkffmpeg.so"
doNotStrip "*/x86_64/libijkplayer.so"
doNotStrip "*/x86_64/libijksdl.so"
}
}
dependencies {
implementation 'com.finogeeks.mop:media:x.y.z' // x.y.z must be replaced with the specific version number
implementation 'tv.danmaku.ijk.media:ijkplayer-java:0.8.8'
}
Add obfuscation rules in the proguard-rules.pro file:
# Media SDK
-keep public class com.finogeeks.finclip.plugins.media.player.ijk.FinIjkMediaPlayerFactory {
public <init>();
}
-keep class com.finogeeks.finclip.plugins.media.player.ijk.IjkMediaPlayerOptionsApplier {
public static <fields>;
public static <methods>;
}
-keep class com.finogeeks.finclip.plugins.media.player.ijk.IjkMediaPlayerOptionsApplier$Applier {*;}
-keep class com.finogeeks.finclip.plugins.media.player.ijk.IjkMediaPlayerOptionsApplier$Options {*;}
#ijkplayer
-keep class tv.danmaku.ijk.media.player.** {*;}
-keep class tv.danmaku.ijk.media.player.IjkMediaPlayer{*;}
-keep class tv.danmaku.ijk.media.player.ffmpeg.FFmpegApi{*;}
# 14. Share SDK
Integrate the Mini-Program sharing feature, taking over the "Share" button function in the "More" menu panel (core SDK version ≥ 2.39.11).
The "Share" button is hidden by default and needs to be configured to display. For details, please refer to: Set Mini-Program More Menu.
If you need to take over the "Share" button click event yourself, please refer to: IShareAppletHandler.
If you need to customize the link of the share landing page and the apk download address in the share link, please refer to: ShareSDKDelegate
Integration method:
implementation 'com.finogeeks.mop:share:x.y.z'
Note
When using the Share SDK, ensure that its version matches the version of the core SDK you are currently using, and that it is 2.39.11 or above.
# 14.1 WeChat Sharing
If you need to enable the WeChat sharing feature, you need to integrate the official WeChat opensdk:
implementation 'com.tencent.mm.opensdk:wechat-sdk-android:6.8.0'
And add the Mobile Application AppID you applied for on the WeChat Open Platform in the project's build.gradle file (e.g., app/build.gradle):
android {
// ..other configuration omitted
defaultConfig {
// ..other configuration omitted
resValue "string", "wechat_sdk_app_id", "Your AppID under the WeChat Open Platform Mobile Application"
}
}
Note
To integrate the Share SDK and use its WeChat-related sharing capabilities, you must first apply for an AppID on the WeChat Open Platform. The AppID filled in here is the AppID under the Mobile Application, which generally starts with wx. Note that it is NOT the AppID of a WeChat Mini-Program, nor the original ID of a WeChat Mini-Program (starting with gh). These IDs are easily confused.
Note
To avoid conflicts with WeChat OpenSDK-related callback classes, the Share SDK will not automatically generate the WeChat callback receiver class WXEntryActivity. Please refer to the official WeChat documentation Android Integration Guide (opens new window) to create WXEntryActivity yourself and add the Share SDK callback handling methods. Example as follows:
class WXEntryActivity : Activity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
FinShareWXEntry.handleWeChatIntent(this, intent)
// Your other business logic
finish()
}
override fun onNewIntent(intent: Intent?) {
super.onNewIntent(intent)
setIntent(intent)
FinShareWXEntry.handleWeChatIntent(this, intent)
// Your other business logic
finish()
}
}
# 15. CastSDK
Supported after version 2.38.1
Quick integration of the Cast SDK, which provides the ability to cast to other devices that support the relevant protocol (DLNA) (e.g., TV) when playing videos.
Integration method:
implementation 'com.finogeeks.mop:cast:x.y.z'
- Add the following configuration to the
build.gradlefile in the root directory of the project to be integrated:
allprojects {
repositories {
maven { url 'http://4thline.org/m2' }
maven { url 'https://jitpack.io' }
}
}
- Add the following configuration to the
app/build.gradlefile in the directory of the project to be integrated:
packagingOptions {
exclude 'META-INF/beans.xml'
}
# 16. LiveSDK
Supported after version 2.41.1
Quick integration of the Live SDK, which provides the capabilities of live streaming push, pull, and playback.
Integration method:
implementation 'com.finogeeks.mop:live:x.y.z'
Note
The Live SDK cannot be used together with WebRTC or AgoraSDK
Note
Perform the following configuration in the project you want to integrate
FinAppConfig.UIConfig uiConfig = new FinAppConfig.UIConfig();
uiConfig.setUseNativeLiveComponent(true); // Do not omit this configuration
FinAppConfig config = new FinAppConfig.Builder()
// Other configurations omitted
.setUiConfig(uiConfig) // Remember to set uiConfig
.build();
FinAppClient.INSTANCE.init(this, config, new FinCallback<Object>() {
@Override
public void onSuccess(Object result) {
// Initialization succeeded, you can start using the live component
// Do not omit this either
AnyRtcLiverSDK.INSTANCE.install();
}
@Override
public void onError(int code, String error) {
}
@Override
public void onProgress(int status, String error) {
}
});
# 17. XLogSDK
Starting from version 2.40.5, the core SDK no longer includes XLog, meaning it no longer includes the ability to persist logs locally.
If you need to persist logs, you can choose to integrate the XLogSDK and enable the corresponding configuration items.
Integration method:
implementation 'com.finogeeks.mop:xlog:x.y.z'
Related configuration:
FinAppConfig finAppConfig = new FinAppConfig.Builder()
// Enable logging, default is false
.setEnableLog(true)
// Enable XLogSDK console logging, default is true
.setEnableXLogConsole(true)
// Set the log level, default is XLogLevel.LEVEL_NONE
.setLogLevel(XLogLevel.LEVEL_VERBOSE)
// Customize the XLogSDK log file directory, default is /data/data/${packageName}/files/fino_log
.setXLogDir(logDir)
// Customize the maximum retention time of XLogSDK log files, minimum 1 day, default is 10 days
.setLogMaxAliveSec(2 * 24 * 60 * 60)
// Other configuration items omitted
.build();
FinAppClient.INSTANCE.init(application, finAppConfig, callback);
Note: If the XLogSDK is not integrated, the configuration items setEnableXLogConsole, setXLogDir, and setLogMaxAliveSec above will be invalid, but setEnableLog and setLogLevel will still take effect, only outputting to the console without persisting logs.
Log export:
/**
* Export logs
*
* @param context
* @param appId Export logs of the specified Mini-Program id; if empty, export the logs of the main process
* @param date Export the log file of the specified date; if empty, export all logs of the main process or the specified Mini-Program
* @param exportDir Export to the specified directory
*/
FinAppClient.INSTANCE.exportLogFile(context, appId, date, exportDir);
Usage examples
Export all logs of the main process:
boolean result = FinAppClient.INSTANCE.exportLogFile(context, null, null, exportDir);
Export the logs of the main process for a specified date:
boolean result = FinAppClient.INSTANCE.exportLogFile(context, null, date, exportDir);
Export all logs of a specified Mini-Program:
boolean result = FinAppClient.INSTANCE.exportLogFile(context, appId, null, exportDir);
Export the logs of a specified Mini-Program for a specified date:
boolean result = FinAppClient.INSTANCE.exportLogFile(context, appId, date, exportDir);
Note: Before exporting, make sure the specified export location
exportDirhas write permission; otherwise, log export may fail.
# 18. CalendarSDK
Using calendar-related APIs requires integrating the Calendar SDK separately. The core SDK version must be higher than 2.40.13. After integration, the APIs will take effect without additional configuration.
Integration method:
implementation 'com.finogeeks.mop:calendar:x.y.z'
# 19. Common Error Codes
# Mini-Program Exception Scenarios
| Mini-Program Exception Scenario | Status Code | Error Message |
|---|---|---|
| Mini-Program does not exist | FS_APP_ID_NOT_FOUND | Mini-Program does not exist : Please check the AppID |
| Mini-Program has been removed | FS_SERVICE_UNAVAILABLE | Mini-Program unavailable : The Mini-Program has been removed, and related services are temporarily unavailable |
| Mini-Program expired | FS_APP_PAY_EXPIRE | Mini-Program unavailable : The Mini-Program has expired, and related services are temporarily unavailable |
| Mini-Program disabled | FS_APP_IS_FORBIDDEN | Mini-Program unavailable : The Mini-Program is disabled, and related services are temporarily unavailable |
| Application does not exist | FS_BIND_NOT_FOUND | Service unavailable: The current application is not registered on the platform, please check the SDK initialization configuration information |
| Application has terminated cooperation | FS_COOPERATION_TERMINATED | Mini-Program unavailable : The current application has terminated cooperation |
| Mini-Program is not associated with the application | FS_APP_NOT_ASS_BIND | Mini-Program unavailable : The association between the Mini-Program and this application has not taken effect, please check the association |
| bundleId disabled | FS_BIND_IS_FORBIDDEN | Mini-Program unavailable : BundleID is disabled, and related services are temporarily unavailable |
| Application expired | FS_BIND_PAY_EXPIRE | Mini-Program unavailable : The current application has expired |
| Organization frozen | FS_ORGAN_STATUS_INVALID | Mini-Program unavailable : The status of the enterprise account to which the Mini-Program belongs is abnormal, please log in to the platform to handle it |
| Invalid license | FS_LICENSE_INVALID_ERR | Mini-Program unavailable : Your current license is abnormal, please contact the administrator |
| Error when requesting Mini-Program version details by Appid and no match is found | FS_APP_SEQUENCE_NOT_FOUND | Failed to open Mini-Program : Mini-Program version error |
| Error when the application cannot be found by SDK KEY | FS_SIGNATURE_SDKKEY_INVAILD | Mini-Program unavailable : SDK Key error, please contact the administrator |
| Failed to get domain | FS_GET_DOMAIN_INFO_ERROR | Service unavailable : Failed to get domain, related services are unavailable |
| Application disabled | - | Mini-Program unavailable : The current cooperating application has been disabled |
| Traffic quota exhausted, unable to open the Mini-Program (whether insufficient call count or code package download traffic, both are resource insufficiency) | OVER_FRQ_LIMIT | Service unavailable : Sorry, due to insufficient resources, related services are temporarily unavailable |
# Common Error Codes During Android Initialization or Mini-Program Startup
| Error Stage | Status Code | Error Message |
|---|---|---|
| Unknown error | 9999 | Unknown error |
| Initialize SDK | 10000 | SDK not initialized or appKey invalid |
| Initialize SDK or open Mini-Program | 10001 | Invalid parameter |
| Open Mini-Program | 10002 | Domain verification failed |
| Open Mini-Program | 10003 | Network not connected |
| Open Mini-Program | 11000 | Server API request failed |
| Open Mini-Program | 11001 | Abnormal data returned by server |
| Open Mini-Program | 11003 | Abnormal download address, unable to download |
| Open Mini-Program | 12002 | service file not found |
| Open Mini-Program | 13000 | No experience permission |
| Open Mini-Program | 13001 | Experience version canceled |
| Open Mini-Program | 13002 | IDE temporary QR code expired |
| Open Mini-Program | 10002 | Environment information of the specified server not configured |
| Open Mini-Program | 12000 | Base Library decompression failed |
| Open Mini-Program | 12000 | Mini-Program decompression failed |
| Open Mini-Program | 13004 | SDK encryption API data decryption failed |
| Open Mini-Program | 11001 | Failed to get Base Library details |
| Open Mini-Program | 11004 | Mini-Program file md5 verification failed |
| Open Mini-Program | 11004 | Server abnormal, download failed |
| Open Mini-Program | 12002 | service file not found |
| Open Mini-Program | 15003 | Device type not supported yet |
| Open Mini-Program | 15004 | The number of currently available devices has reached the upper limit |
| Open Mini-Program | 15005 | Mini-Program not found |
| Open Mini-Program | 15006 | Page does not exist |