Help Center/ Meeting/ Client SDK Reference/ Android SDK/ Typical Scenarios/ Scenario 2: Login Using an Account and Password
Updated on 2023-03-23 GMT+08:00

Scenario 2: Login Using an Account and Password

Description

Before using HUAWEI CLOUD Meeting, you must complete login authentication on the server.

If you have not logged in, you can only join created meetings.

Service Process

  1. Call the API.

    1. Create a LoginParam object.
      1. Select a proper login type.
      2. Set the account and password.
    2. Call the login API to log in. The data in the preceding step is used as input parameters.

  2. Implement the callback.

    Process the result in the callback.

Sample Code

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
// Create a login object.
LoginParam loginParam = new LoginParam()                 
    .setLoginAuthType(LoginAuthType.Account_And_Password)      
    .setAccount("huawei")            // Set the login account.
    .setPassword("123456");          // Set the login password.
// Start to log in.
HWMSdk.getOpenApi(getApplication()).login(loginParam, new HwmCallback<LoginResult>() {
            @Override
            public void onSuccess(LoginResult loginResult) {
                Log.i(TAG, "Login succeeded");
            }
            @Override
            public void onFailed(final int retCode, String desc) {
                HwmContext.getInstance().runOnMainThread(new Runnable() {
                    @Override
                    public void run() {
                        Error error = HWMBizSdk.getLoginApi().convertErrorCodeToUI(retCode);
                        Log.i(TAG, "Login failed: "+ error.getMessage());
                    }
                });
            }
        });

Precautions

The login API can be called only after HWMSdk.init is successfully called.