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

Scenario 8: Initiating a Call

Description

Huawei Cloud Meeting allows you to initiate P2P voice and video calls, in the prerequisites that you have logged in to Huawei Cloud Meeting.

Service Process

  1. Call an API.

    1. Create a CallParam object.
       1
       2
       3
       4
       5
       6
       7
       8
       9
      10
      11
      12
      13
      14
      15
      16
      17
      18
      19
      20
      21
      22
      23
      24
      25
      26
      27
      28
      29
             // Create a CallParam object.
              CallParam callParam = new CallParam()
                      .setVideo(true);// Specify whether to use video.
      
              String name = "huawei123456";
              String number = "+99123456xxx";
              String thirdAccountId = "123456abcd";
              String accountUuid= "uuidid123456";
      
              // The following four methods are available:
              if (!TextUtils.isEmpty(number)) {
                  // Use a SIP number to make a call.
                  callParam.setNumber(number);
              }
      
              if (!TextUtils.isEmpty(account)) {
                  // Use an account in the HUAWEI corporate directory to make a call.
                  callParam.setAccount(account);
              }
      
              if (!TextUtils.isEmpty(thirdAccountId)) {
                   // Use a contact ID in the third-party address book to make a call, if you log in using the app ID.
                  callParam.setThirdAccountId(thirdAccountId);
              }
      
              if (!TextUtils.isEmpty(accountUuid)) {
                  // Use an ID in the HUAWEI corporate directory to make a call.
                  callParam.setCalleeUuid(accountUuid);
              }
      
    2. Call the startCall API to initiate the call. 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
// Initiate a call.
HWMSdk.getOpenApi(getActivity()).startCall(callParam, new HwmCancelableCallBack<Void>() {             
    @Override             
    public void onSuccess(Void result) {                 
         Log.i(TAG, "Call succeeded");
    }              
    @Override             
    public void onFailed(int retCode, String desc) {                 
         Log.i(TAG,  "Call failed: "+ retCode +", desc: " + desc);
    }         
    @Override
    public void onCancel() {
    
    }
});