Updated on 2023-03-23 GMT+08:00

Scenario 1: Initialization

Description

Before using SDK service components, initialize the basic components of the SDK.

There are synchronous initialization and asynchronous initialization APIs. The initialization takes about 1 to 2 seconds. If there are requirements on the app startup speed, use the asynchronous initialization API.

Synchronous Initialization Process

  1. Call the API.

    1. Call HWMSdk.init(Application, OpenSDKConfig) to initialize the SDK. Before initialization, you can customize the SDK. For details on the configuration procedure and sample code, see 8. Initialize the SDK.

Asynchronous Initialization Process

  1. Register a listener.

    Listen to the activity lifecycle in Application.

    registerActivityLifecycleCallbacks(new ActivityLifecycleHandle());

  2. Call an API.

    1. Call HWMSdk.initAsync(Application, OpenSDKConfig, SdkCallback) to initialize the SDK asynchronously. Before initialization, you can customize the SDK. For details on the configuration procedure and sample code, see 8. Initialize the SDK.

  3. Process the callback.

    1. Listen to the onSuccess callback and call other APIs after the Android SDK is initialized.

Notes

1. During asynchronous initialization, you must listen to the activity lifecycle (step 1). If this step is skipped, multiple functions of the SDK will be affected. Perform step 1 before calling the initialization API.

2. Asynchronous initialization can be performed in a subthread. Use other SDK functions after the initialization is complete.

3. The Application parameter in the initialization API must be specified to ensure successful initialization. If you log in to Huawei Cloud Meeting using an app ID, call OpenSDKConfig.setAppId to set the Application parameter.