1e41f4b71Sopenharmony_ci# @ohos.telephony.call (Call) 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ciThe **call** module provides call management functions, including making calls, redirecting to the dial screen, obtaining the call status, and formatting phone numbers. 4e41f4b71Sopenharmony_ci 5e41f4b71Sopenharmony_ciTo subscribe to call status changes, use [`observer.on('callStateChange')`](js-apis-observer.md#observeroncallstatechange). 6e41f4b71Sopenharmony_ci 7e41f4b71Sopenharmony_ci>**NOTE** 8e41f4b71Sopenharmony_ci> 9e41f4b71Sopenharmony_ci>The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version. 10e41f4b71Sopenharmony_ci 11e41f4b71Sopenharmony_ci## Modules to Import 12e41f4b71Sopenharmony_ci 13e41f4b71Sopenharmony_ci```ts 14e41f4b71Sopenharmony_ciimport { call } from '@kit.TelephonyKit'; 15e41f4b71Sopenharmony_ci``` 16e41f4b71Sopenharmony_ci 17e41f4b71Sopenharmony_ci 18e41f4b71Sopenharmony_ci## call.dial<sup>(deprecated)</sup> 19e41f4b71Sopenharmony_ci 20e41f4b71Sopenharmony_cidial\(phoneNumber: string, callback: AsyncCallback\<boolean\>\): void 21e41f4b71Sopenharmony_ci 22e41f4b71Sopenharmony_ciInitiates a call. This API uses an asynchronous callback to return the result. 23e41f4b71Sopenharmony_ci 24e41f4b71Sopenharmony_ci> **NOTE** 25e41f4b71Sopenharmony_ci> 26e41f4b71Sopenharmony_ci> This API is supported since API version 6 and deprecated since API version 9. The substitute API is available only for system applications. 27e41f4b71Sopenharmony_ci 28e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.PLACE_CALL (available only for system applications) 29e41f4b71Sopenharmony_ci 30e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Telephony.CallManager 31e41f4b71Sopenharmony_ci 32e41f4b71Sopenharmony_ci**Parameters** 33e41f4b71Sopenharmony_ci 34e41f4b71Sopenharmony_ci| Name | Type | Mandatory| Description | 35e41f4b71Sopenharmony_ci| ----------- | ---------------------------- | ---- | --------------------------------------- | 36e41f4b71Sopenharmony_ci| phoneNumber | string | Yes | Phone number. | 37e41f4b71Sopenharmony_ci| callback | AsyncCallback<boolean> | Yes | Callback used to return the result. The value **true** indicates that the operation is successful, and the value **false** indicates the opposite.| 38e41f4b71Sopenharmony_ci 39e41f4b71Sopenharmony_ci**Example** 40e41f4b71Sopenharmony_ci 41e41f4b71Sopenharmony_ci```ts 42e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 43e41f4b71Sopenharmony_ci 44e41f4b71Sopenharmony_cicall.dial("138xxxxxxxx", (err: BusinessError, data: boolean) => { 45e41f4b71Sopenharmony_ci console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); 46e41f4b71Sopenharmony_ci}); 47e41f4b71Sopenharmony_ci``` 48e41f4b71Sopenharmony_ci 49e41f4b71Sopenharmony_ci 50e41f4b71Sopenharmony_ci## call.dial<sup>(deprecated)</sup> 51e41f4b71Sopenharmony_ci 52e41f4b71Sopenharmony_cidial\(phoneNumber: string, options: DialOptions, callback: AsyncCallback\<boolean\>\): void 53e41f4b71Sopenharmony_ci 54e41f4b71Sopenharmony_ciInitiates a call. You can set call options as needed. This API uses an asynchronous callback to return the result. 55e41f4b71Sopenharmony_ci 56e41f4b71Sopenharmony_ci> **NOTE** 57e41f4b71Sopenharmony_ci> 58e41f4b71Sopenharmony_ci> This API is supported since API version 6 and deprecated since API version 9. The substitute API is available only for system applications. 59e41f4b71Sopenharmony_ci 60e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.PLACE_CALL (available only for system applications) 61e41f4b71Sopenharmony_ci 62e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Telephony.CallManager 63e41f4b71Sopenharmony_ci 64e41f4b71Sopenharmony_ci**Parameters** 65e41f4b71Sopenharmony_ci 66e41f4b71Sopenharmony_ci| Name | Type | Mandatory| Description | 67e41f4b71Sopenharmony_ci| ----------- | ---------------------------- | ---- | --------------------------------------- | 68e41f4b71Sopenharmony_ci| phoneNumber | string | Yes | Phone number. | 69e41f4b71Sopenharmony_ci| options | [DialOptions](#dialoptions) | Yes | Call option, which indicates whether the call is a voice call or video call. | 70e41f4b71Sopenharmony_ci| callback | AsyncCallback<boolean> | Yes | Callback used to return the result. The value **true** indicates that the operation is successful, and the value **false** indicates the opposite.| 71e41f4b71Sopenharmony_ci 72e41f4b71Sopenharmony_ci**Example** 73e41f4b71Sopenharmony_ci 74e41f4b71Sopenharmony_ci```ts 75e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 76e41f4b71Sopenharmony_ci 77e41f4b71Sopenharmony_cilet dialOptions: call.DialOptions = { 78e41f4b71Sopenharmony_ci extras: false 79e41f4b71Sopenharmony_ci} 80e41f4b71Sopenharmony_cicall.dial("138xxxxxxxx", dialOptions, (err: BusinessError, data: boolean) => { 81e41f4b71Sopenharmony_ci console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); 82e41f4b71Sopenharmony_ci}); 83e41f4b71Sopenharmony_ci``` 84e41f4b71Sopenharmony_ci 85e41f4b71Sopenharmony_ci## call.dial<sup>(deprecated)</sup> 86e41f4b71Sopenharmony_ci 87e41f4b71Sopenharmony_cidial\(phoneNumber: string, options?: DialOptions\): Promise\<boolean\> 88e41f4b71Sopenharmony_ci 89e41f4b71Sopenharmony_ciInitiates a call. You can set call options as needed. This API uses a promise to return the result. 90e41f4b71Sopenharmony_ci 91e41f4b71Sopenharmony_ci> **NOTE** 92e41f4b71Sopenharmony_ci> 93e41f4b71Sopenharmony_ci> This API is supported since API version 6 and deprecated since API version 9. The substitute API is available only for system applications. 94e41f4b71Sopenharmony_ci 95e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.PLACE_CALL (available only for system applications) 96e41f4b71Sopenharmony_ci 97e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Telephony.CallManager 98e41f4b71Sopenharmony_ci 99e41f4b71Sopenharmony_ci**Parameters** 100e41f4b71Sopenharmony_ci 101e41f4b71Sopenharmony_ci| Name | Type | Mandatory| Description | 102e41f4b71Sopenharmony_ci| ----------- | --------------------------- | ---- | -------------------------------------- | 103e41f4b71Sopenharmony_ci| phoneNumber | string | Yes | Phone number. | 104e41f4b71Sopenharmony_ci| options | [DialOptions](#dialoptions) | No | Call option, which indicates whether the call is a voice call or video call.| 105e41f4b71Sopenharmony_ci 106e41f4b71Sopenharmony_ci**Return value** 107e41f4b71Sopenharmony_ci 108e41f4b71Sopenharmony_ci| Type | Description | 109e41f4b71Sopenharmony_ci| ---------------------- | ------------------------------------------------------------ | 110e41f4b71Sopenharmony_ci| Promise<boolean> | Promise used to return the result. The value **true** indicates that the operation is successful, and the value **false** indicates the opposite.| 111e41f4b71Sopenharmony_ci 112e41f4b71Sopenharmony_ci**Example** 113e41f4b71Sopenharmony_ci 114e41f4b71Sopenharmony_ci```ts 115e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 116e41f4b71Sopenharmony_ci 117e41f4b71Sopenharmony_cilet dialOptions: call.DialOptions = { 118e41f4b71Sopenharmony_ci extras: false 119e41f4b71Sopenharmony_ci} 120e41f4b71Sopenharmony_cicall.dial("138xxxxxxxx", dialOptions).then((data: boolean) => { 121e41f4b71Sopenharmony_ci console.log(`dial success, promise: data->${JSON.stringify(data)}`); 122e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => { 123e41f4b71Sopenharmony_ci console.error(`dial fail, promise: err->${JSON.stringify(err)}`); 124e41f4b71Sopenharmony_ci}); 125e41f4b71Sopenharmony_ci``` 126e41f4b71Sopenharmony_ci 127e41f4b71Sopenharmony_ci## call.makeCall<sup>7+</sup> 128e41f4b71Sopenharmony_ci 129e41f4b71Sopenharmony_cimakeCall\(phoneNumber: string, callback: AsyncCallback\<void\>\): void 130e41f4b71Sopenharmony_ci 131e41f4b71Sopenharmony_ciLaunches the call screen and displays the dialed number. This API uses an asynchronous callback to return the result. This API can be called only in a UIAbility. 132e41f4b71Sopenharmony_ci 133e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11. 134e41f4b71Sopenharmony_ci 135e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Applications.Contacts 136e41f4b71Sopenharmony_ci 137e41f4b71Sopenharmony_ci**Parameters** 138e41f4b71Sopenharmony_ci 139e41f4b71Sopenharmony_ci| Name | Type | Mandatory| Description | 140e41f4b71Sopenharmony_ci| ----------- | ------------------------- | ---- | ------------------------------------------ | 141e41f4b71Sopenharmony_ci| phoneNumber | string | Yes | Phone number. | 142e41f4b71Sopenharmony_ci| callback | AsyncCallback<void> | Yes | Callback used to return the result.| 143e41f4b71Sopenharmony_ci 144e41f4b71Sopenharmony_ci**Error codes** 145e41f4b71Sopenharmony_ci 146e41f4b71Sopenharmony_ciFor details about the error codes, see [ohos.telephony (Telephony) Error Codes](errorcode-telephony.md) and [Universal Error Codes](../errorcode-universal.md). 147e41f4b71Sopenharmony_ci 148e41f4b71Sopenharmony_ci| ID| Error Message | 149e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- | 150e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2. Incorrect parameters types;| 151e41f4b71Sopenharmony_ci| 8300001 | Invalid parameter value. | 152e41f4b71Sopenharmony_ci| 8300002 | Operation failed. Cannot connect to service. | 153e41f4b71Sopenharmony_ci| 8300003 | System internal error. | 154e41f4b71Sopenharmony_ci| 8300999 | Unknown error code. | 155e41f4b71Sopenharmony_ci 156e41f4b71Sopenharmony_ci**Example** 157e41f4b71Sopenharmony_ci 158e41f4b71Sopenharmony_ci```ts 159e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 160e41f4b71Sopenharmony_ci 161e41f4b71Sopenharmony_cicall.makeCall("138xxxxxxxx", (err: BusinessError) => { 162e41f4b71Sopenharmony_ci if (err) { 163e41f4b71Sopenharmony_ci console.error(`makeCall fail, err->${JSON.stringify(err)}`); 164e41f4b71Sopenharmony_ci } else { 165e41f4b71Sopenharmony_ci console.log(`makeCall success`); 166e41f4b71Sopenharmony_ci } 167e41f4b71Sopenharmony_ci}); 168e41f4b71Sopenharmony_ci``` 169e41f4b71Sopenharmony_ci 170e41f4b71Sopenharmony_ci 171e41f4b71Sopenharmony_ci## call.makeCall<sup>7+</sup> 172e41f4b71Sopenharmony_ci 173e41f4b71Sopenharmony_cimakeCall\(phoneNumber: string\): Promise\<void\> 174e41f4b71Sopenharmony_ci 175e41f4b71Sopenharmony_ciLaunches the call screen and displays the dialed number. This API uses a promise to return the result. This API can be called only in a UIAbility. 176e41f4b71Sopenharmony_ci 177e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11. 178e41f4b71Sopenharmony_ci 179e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Applications.Contacts 180e41f4b71Sopenharmony_ci 181e41f4b71Sopenharmony_ci**Parameters** 182e41f4b71Sopenharmony_ci 183e41f4b71Sopenharmony_ci| Name | Type | Mandatory| Description | 184e41f4b71Sopenharmony_ci| ----------- | ------ | ---- | ---------- | 185e41f4b71Sopenharmony_ci| phoneNumber | string | Yes | Phone number.| 186e41f4b71Sopenharmony_ci 187e41f4b71Sopenharmony_ci**Return value** 188e41f4b71Sopenharmony_ci 189e41f4b71Sopenharmony_ci| Type | Description | 190e41f4b71Sopenharmony_ci| ------------------- | --------------------------------- | 191e41f4b71Sopenharmony_ci| Promise<void> | Promise used to return the result.| 192e41f4b71Sopenharmony_ci 193e41f4b71Sopenharmony_ci**Error codes** 194e41f4b71Sopenharmony_ci 195e41f4b71Sopenharmony_ciFor details about the error codes, see [ohos.telephony (Telephony) Error Codes](errorcode-telephony.md) and [Universal Error Codes](../errorcode-universal.md). 196e41f4b71Sopenharmony_ci 197e41f4b71Sopenharmony_ci| ID| Error Message | 198e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- | 199e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2. Incorrect parameters types;| 200e41f4b71Sopenharmony_ci| 8300001 | Invalid parameter value. | 201e41f4b71Sopenharmony_ci| 8300002 | Operation failed. Cannot connect to service. | 202e41f4b71Sopenharmony_ci| 8300003 | System internal error. | 203e41f4b71Sopenharmony_ci| 8300999 | Unknown error code. | 204e41f4b71Sopenharmony_ci 205e41f4b71Sopenharmony_ci**Example** 206e41f4b71Sopenharmony_ci 207e41f4b71Sopenharmony_ci```ts 208e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 209e41f4b71Sopenharmony_ci 210e41f4b71Sopenharmony_cicall.makeCall("138xxxxxxxx").then(() => { 211e41f4b71Sopenharmony_ci console.log(`makeCall success`); 212e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => { 213e41f4b71Sopenharmony_ci console.error(`makeCall fail, promise: err->${JSON.stringify(err)}`); 214e41f4b71Sopenharmony_ci}); 215e41f4b71Sopenharmony_ci``` 216e41f4b71Sopenharmony_ci 217e41f4b71Sopenharmony_ci## call.makeCall<sup>12+</sup> 218e41f4b71Sopenharmony_ci 219e41f4b71Sopenharmony_cimakeCall\(context: Context, phoneNumber: string\): Promise\<void\> 220e41f4b71Sopenharmony_ci 221e41f4b71Sopenharmony_ciLaunches the call screen and displays the dialed number. This API uses a promise to return the result. You need to declare the **ohos.permission.START_ABILITIES_FROM_BACKGROUND** permission if you want to call the API in the background. 222e41f4b71Sopenharmony_ci 223e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12. 224e41f4b71Sopenharmony_ci 225e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Applications.Contacts 226e41f4b71Sopenharmony_ci 227e41f4b71Sopenharmony_ci**Parameters** 228e41f4b71Sopenharmony_ci 229e41f4b71Sopenharmony_ci| Name | Type | Mandatory| Description | 230e41f4b71Sopenharmony_ci| ----------- | ------ | ---- | ---------- | 231e41f4b71Sopenharmony_ci| context | Context | Yes | Application context.| 232e41f4b71Sopenharmony_ci| phoneNumber | string | Yes | Phone number.| 233e41f4b71Sopenharmony_ci 234e41f4b71Sopenharmony_ci**Return value** 235e41f4b71Sopenharmony_ci 236e41f4b71Sopenharmony_ci| Type | Description | 237e41f4b71Sopenharmony_ci| ------------------- | --------------------------------- | 238e41f4b71Sopenharmony_ci| Promise<void> | Promise used to return the result.| 239e41f4b71Sopenharmony_ci 240e41f4b71Sopenharmony_ci**Error codes** 241e41f4b71Sopenharmony_ci 242e41f4b71Sopenharmony_ciFor details about the error codes, see [ohos.telephony (Telephony) Error Codes](errorcode-telephony.md) and [Universal Error Codes](../errorcode-universal.md). 243e41f4b71Sopenharmony_ci 244e41f4b71Sopenharmony_ci| ID| Error Message | 245e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- | 246e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2. Incorrect parameters types;| 247e41f4b71Sopenharmony_ci| 8300002 | Operation failed. Cannot connect to service. | 248e41f4b71Sopenharmony_ci| 8300003 | System internal error. | 249e41f4b71Sopenharmony_ci 250e41f4b71Sopenharmony_ci**Example** 251e41f4b71Sopenharmony_ci 252e41f4b71Sopenharmony_ci```ts 253e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 254e41f4b71Sopenharmony_ci// Obtain the application context. 255e41f4b71Sopenharmony_cilet context = getContext(this) as Context; 256e41f4b71Sopenharmony_cicall.makeCall(context, "138xxxxxxxx").then(() => { 257e41f4b71Sopenharmony_ci console.log(`makeCall success`); 258e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => { 259e41f4b71Sopenharmony_ci console.error(`makeCall fail, promise: err->${JSON.stringify(err)}`); 260e41f4b71Sopenharmony_ci}); 261e41f4b71Sopenharmony_ci``` 262e41f4b71Sopenharmony_ci 263e41f4b71Sopenharmony_ci## call.hasCall 264e41f4b71Sopenharmony_ci 265e41f4b71Sopenharmony_cihasCall\(callback: AsyncCallback\<boolean\>\): void 266e41f4b71Sopenharmony_ci 267e41f4b71Sopenharmony_ciChecks whether a call is in progress. This API uses an asynchronous callback to return the result. 268e41f4b71Sopenharmony_ci 269e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Telephony.CallManager 270e41f4b71Sopenharmony_ci 271e41f4b71Sopenharmony_ci**Parameters** 272e41f4b71Sopenharmony_ci 273e41f4b71Sopenharmony_ci| Name | Type | Mandatory| Description | 274e41f4b71Sopenharmony_ci| -------- | ---------------------------- | ---- | ------------------------------------------------------------ | 275e41f4b71Sopenharmony_ci| callback | AsyncCallback<boolean> | Yes | Callback used to return the result. The value **true** indicates that a call is in progress, and the value **false** indicates the opposite.| 276e41f4b71Sopenharmony_ci 277e41f4b71Sopenharmony_ci**Example** 278e41f4b71Sopenharmony_ci 279e41f4b71Sopenharmony_ci```ts 280e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 281e41f4b71Sopenharmony_ci 282e41f4b71Sopenharmony_cicall.hasCall((err: BusinessError, data: boolean) => { 283e41f4b71Sopenharmony_ci if (err) { 284e41f4b71Sopenharmony_ci console.error(`hasCall fail, err->${JSON.stringify(err)}`); 285e41f4b71Sopenharmony_ci } else { 286e41f4b71Sopenharmony_ci console.log(`hasCall success, data->${JSON.stringify(data)}`); 287e41f4b71Sopenharmony_ci } 288e41f4b71Sopenharmony_ci}); 289e41f4b71Sopenharmony_ci``` 290e41f4b71Sopenharmony_ci 291e41f4b71Sopenharmony_ci 292e41f4b71Sopenharmony_ci## call.hasCall 293e41f4b71Sopenharmony_ci 294e41f4b71Sopenharmony_cihasCall\(\): Promise\<boolean\> 295e41f4b71Sopenharmony_ci 296e41f4b71Sopenharmony_ciChecks whether a call is in progress. This API uses a promise to return the result. 297e41f4b71Sopenharmony_ci 298e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Telephony.CallManager 299e41f4b71Sopenharmony_ci 300e41f4b71Sopenharmony_ci**Return value** 301e41f4b71Sopenharmony_ci 302e41f4b71Sopenharmony_ci| Type | Description | 303e41f4b71Sopenharmony_ci| ---------------------- | --------------------------------------- | 304e41f4b71Sopenharmony_ci| Promise<boolean> | Promise used to return the result. The value **true** indicates that a call is in progress, and the value **false** indicates the opposite.| 305e41f4b71Sopenharmony_ci 306e41f4b71Sopenharmony_ci**Example** 307e41f4b71Sopenharmony_ci 308e41f4b71Sopenharmony_ci```ts 309e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 310e41f4b71Sopenharmony_ci 311e41f4b71Sopenharmony_cicall.hasCall().then(() => { 312e41f4b71Sopenharmony_ci console.log(`hasCall success`); 313e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => { 314e41f4b71Sopenharmony_ci console.error(`hasCall fail, promise: err->${JSON.stringify(err)}`); 315e41f4b71Sopenharmony_ci}); 316e41f4b71Sopenharmony_ci``` 317e41f4b71Sopenharmony_ci 318e41f4b71Sopenharmony_ci## call.hasCallSync<sup>10+</sup> 319e41f4b71Sopenharmony_ci 320e41f4b71Sopenharmony_cihasCallSync\(\): boolean 321e41f4b71Sopenharmony_ci 322e41f4b71Sopenharmony_ciChecks whether a call is in progress. 323e41f4b71Sopenharmony_ci 324e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Telephony.CallManager 325e41f4b71Sopenharmony_ci 326e41f4b71Sopenharmony_ci**Return value** 327e41f4b71Sopenharmony_ci 328e41f4b71Sopenharmony_ci| Type | Description | 329e41f4b71Sopenharmony_ci| ---------------------- |-------------| 330e41f4b71Sopenharmony_ci| boolean | Promise used to return the result. The value **true** indicates that a call is in progress, and the value **false** indicates the opposite.| 331e41f4b71Sopenharmony_ci 332e41f4b71Sopenharmony_ci**Example** 333e41f4b71Sopenharmony_ci 334e41f4b71Sopenharmony_ci```ts 335e41f4b71Sopenharmony_cilet hasCall: boolean = call.hasCallSync(); 336e41f4b71Sopenharmony_ciconsole.log(`hasCallSync success, has call is ` + hasCall); 337e41f4b71Sopenharmony_ci``` 338e41f4b71Sopenharmony_ci 339e41f4b71Sopenharmony_ci 340e41f4b71Sopenharmony_ci## call.getCallState 341e41f4b71Sopenharmony_ci 342e41f4b71Sopenharmony_cigetCallState\(callback: AsyncCallback\<CallState\>\): void 343e41f4b71Sopenharmony_ci 344e41f4b71Sopenharmony_ciObtains the call status. This API uses an asynchronous callback to return the result. 345e41f4b71Sopenharmony_ci 346e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Telephony.CallManager 347e41f4b71Sopenharmony_ci 348e41f4b71Sopenharmony_ci**Parameters** 349e41f4b71Sopenharmony_ci 350e41f4b71Sopenharmony_ci| Name | Type | Mandatory| Description | 351e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- | ---- | ------------------------------------ | 352e41f4b71Sopenharmony_ci| callback | AsyncCallback<[CallState](#callstate)> | Yes | Callback used to return the result.| 353e41f4b71Sopenharmony_ci 354e41f4b71Sopenharmony_ci**Example** 355e41f4b71Sopenharmony_ci 356e41f4b71Sopenharmony_ci```ts 357e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 358e41f4b71Sopenharmony_ci 359e41f4b71Sopenharmony_cicall.getCallState((err: BusinessError, data: call.CallState) => { 360e41f4b71Sopenharmony_ci if (err) { 361e41f4b71Sopenharmony_ci console.error(`getCallState fail, err->${JSON.stringify(err)}`); 362e41f4b71Sopenharmony_ci } else { 363e41f4b71Sopenharmony_ci console.log(`getCallState success, data->${JSON.stringify(data)}`); 364e41f4b71Sopenharmony_ci } 365e41f4b71Sopenharmony_ci}); 366e41f4b71Sopenharmony_ci``` 367e41f4b71Sopenharmony_ci 368e41f4b71Sopenharmony_ci 369e41f4b71Sopenharmony_ci## call.getCallState 370e41f4b71Sopenharmony_ci 371e41f4b71Sopenharmony_cigetCallState\(\): Promise\<CallState\> 372e41f4b71Sopenharmony_ci 373e41f4b71Sopenharmony_ciObtains the call status. This API uses a promise to return the result. 374e41f4b71Sopenharmony_ci 375e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Telephony.CallManager 376e41f4b71Sopenharmony_ci 377e41f4b71Sopenharmony_ci**Return value** 378e41f4b71Sopenharmony_ci 379e41f4b71Sopenharmony_ci| Type | Description | 380e41f4b71Sopenharmony_ci| -------------------------------------- | --------------------------------------- | 381e41f4b71Sopenharmony_ci| Promise<[CallState](#callstate)> | Promise used to return the result.| 382e41f4b71Sopenharmony_ci 383e41f4b71Sopenharmony_ci**Example** 384e41f4b71Sopenharmony_ci 385e41f4b71Sopenharmony_ci```ts 386e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 387e41f4b71Sopenharmony_ci 388e41f4b71Sopenharmony_cicall.getCallState().then((data: call.CallState) => { 389e41f4b71Sopenharmony_ci console.log(`getCallState success, promise: data->${JSON.stringify(data)}`); 390e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => { 391e41f4b71Sopenharmony_ci console.error(`getCallState fail, promise: err->${JSON.stringify(err)}`); 392e41f4b71Sopenharmony_ci}); 393e41f4b71Sopenharmony_ci``` 394e41f4b71Sopenharmony_ci 395e41f4b71Sopenharmony_ci## call.getCallStateSync<sup>10+</sup> 396e41f4b71Sopenharmony_ci 397e41f4b71Sopenharmony_cigetCallStateSync\(\): CallState 398e41f4b71Sopenharmony_ci 399e41f4b71Sopenharmony_ciObtains the call status. 400e41f4b71Sopenharmony_ci 401e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Telephony.CallManager 402e41f4b71Sopenharmony_ci 403e41f4b71Sopenharmony_ci**Return value** 404e41f4b71Sopenharmony_ci 405e41f4b71Sopenharmony_ci| Type | Description | 406e41f4b71Sopenharmony_ci| ------------------------------------- |-------------| 407e41f4b71Sopenharmony_ci| [CallState](#callstate) | Promise used to return the result.| 408e41f4b71Sopenharmony_ci 409e41f4b71Sopenharmony_ci**Example** 410e41f4b71Sopenharmony_ci 411e41f4b71Sopenharmony_ci```ts 412e41f4b71Sopenharmony_cilet callState: call.CallState = call.getCallStateSync(); 413e41f4b71Sopenharmony_ciconsole.log(`the call state is:` + callState); 414e41f4b71Sopenharmony_ci``` 415e41f4b71Sopenharmony_ci 416e41f4b71Sopenharmony_ci## call.hasVoiceCapability<sup>7+</sup> 417e41f4b71Sopenharmony_ci 418e41f4b71Sopenharmony_cihasVoiceCapability\(\): boolean 419e41f4b71Sopenharmony_ci 420e41f4b71Sopenharmony_ciChecks whether a device supports voice calls. 421e41f4b71Sopenharmony_ci 422e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Telephony.CallManager 423e41f4b71Sopenharmony_ci 424e41f4b71Sopenharmony_ci**Return value** 425e41f4b71Sopenharmony_ci 426e41f4b71Sopenharmony_ci| Type | Description | 427e41f4b71Sopenharmony_ci| ------- | ------------------------------------------------------------ | 428e41f4b71Sopenharmony_ci| boolean | Result indicating whether the device supports voice calls. The value **true** indicates yes, and the value **false** indicates no.| 429e41f4b71Sopenharmony_ci 430e41f4b71Sopenharmony_ci```ts 431e41f4b71Sopenharmony_cilet result: boolean = call.hasVoiceCapability(); 432e41f4b71Sopenharmony_ciconsole.log(`hasVoiceCapability: ${JSON.stringify(result)}`); 433e41f4b71Sopenharmony_ci``` 434e41f4b71Sopenharmony_ci 435e41f4b71Sopenharmony_ci## call.isEmergencyPhoneNumber<sup>7+</sup> 436e41f4b71Sopenharmony_ci 437e41f4b71Sopenharmony_ciisEmergencyPhoneNumber\(phoneNumber: string, callback: AsyncCallback\<boolean\>\): void 438e41f4b71Sopenharmony_ci 439e41f4b71Sopenharmony_ciChecks whether the called number is an emergency number. This API uses an asynchronous callback to return the result. 440e41f4b71Sopenharmony_ci 441e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Telephony.CallManager 442e41f4b71Sopenharmony_ci 443e41f4b71Sopenharmony_ci**Parameters** 444e41f4b71Sopenharmony_ci 445e41f4b71Sopenharmony_ci| Name | Type | Mandatory| Description | 446e41f4b71Sopenharmony_ci| ----------- | ---------------------------- | ---- | ------------------------------------------------------------ | 447e41f4b71Sopenharmony_ci| phoneNumber | string | Yes | Phone number. | 448e41f4b71Sopenharmony_ci| callback | AsyncCallback<boolean> | Yes | Callback used to return the result. The value **true** indicates that the called number is an emergency number, and the value **false** indicates the opposite.| 449e41f4b71Sopenharmony_ci 450e41f4b71Sopenharmony_ci**Error codes** 451e41f4b71Sopenharmony_ci 452e41f4b71Sopenharmony_ciFor details about the error codes, see [ohos.telephony (Telephony) Error Codes](errorcode-telephony.md) and [Universal Error Codes](../errorcode-universal.md). 453e41f4b71Sopenharmony_ci 454e41f4b71Sopenharmony_ci| ID| Error Message | 455e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- | 456e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2. Incorrect parameters types;| 457e41f4b71Sopenharmony_ci| 8300001 | Invalid parameter value. | 458e41f4b71Sopenharmony_ci| 8300002 | Operation failed. Cannot connect to service. | 459e41f4b71Sopenharmony_ci| 8300003 | System internal error. | 460e41f4b71Sopenharmony_ci| 8300999 | Unknown error code. | 461e41f4b71Sopenharmony_ci 462e41f4b71Sopenharmony_ci**Example** 463e41f4b71Sopenharmony_ci 464e41f4b71Sopenharmony_ci```ts 465e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 466e41f4b71Sopenharmony_ci 467e41f4b71Sopenharmony_cicall.isEmergencyPhoneNumber("138xxxxxxxx", (err: BusinessError, data: boolean) => { 468e41f4b71Sopenharmony_ci if (err) { 469e41f4b71Sopenharmony_ci console.error(`isEmergencyPhoneNumber fail, err->${JSON.stringify(err)}`); 470e41f4b71Sopenharmony_ci } else { 471e41f4b71Sopenharmony_ci console.log(`isEmergencyPhoneNumber success, data->${JSON.stringify(data)}`); 472e41f4b71Sopenharmony_ci } 473e41f4b71Sopenharmony_ci}); 474e41f4b71Sopenharmony_ci``` 475e41f4b71Sopenharmony_ci 476e41f4b71Sopenharmony_ci 477e41f4b71Sopenharmony_ci## call.isEmergencyPhoneNumber<sup>7+</sup> 478e41f4b71Sopenharmony_ci 479e41f4b71Sopenharmony_ciisEmergencyPhoneNumber\(phoneNumber: string, options: EmergencyNumberOptions, callback: AsyncCallback\<boolean\>\): void 480e41f4b71Sopenharmony_ci 481e41f4b71Sopenharmony_ciChecks whether the called number is an emergency number based on the phone number. This API uses an asynchronous callback to return the result. 482e41f4b71Sopenharmony_ci 483e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Telephony.CallManager 484e41f4b71Sopenharmony_ci 485e41f4b71Sopenharmony_ci**Parameters** 486e41f4b71Sopenharmony_ci 487e41f4b71Sopenharmony_ci| Name | Type | Mandatory| Description | 488e41f4b71Sopenharmony_ci| ----------- | -------------------------------------------------- | ---- | ------------------------------------------------------------ | 489e41f4b71Sopenharmony_ci| phoneNumber | string | Yes | Phone number. | 490e41f4b71Sopenharmony_ci| options | [EmergencyNumberOptions](#emergencynumberoptions7) | Yes | Emergency number options. | 491e41f4b71Sopenharmony_ci| callback | AsyncCallback<boolean> | Yes | Callback used to return the result. The value **true** indicates that the called number is an emergency number, and the value **false** indicates the opposite.| 492e41f4b71Sopenharmony_ci 493e41f4b71Sopenharmony_ci**Error codes** 494e41f4b71Sopenharmony_ci 495e41f4b71Sopenharmony_ciFor details about the error codes, see [ohos.telephony (Telephony) Error Codes](errorcode-telephony.md) and [Universal Error Codes](../errorcode-universal.md). 496e41f4b71Sopenharmony_ci 497e41f4b71Sopenharmony_ci| ID| Error Message | 498e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- | 499e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2. Incorrect parameters types;| 500e41f4b71Sopenharmony_ci| 8300001 | Invalid parameter value. | 501e41f4b71Sopenharmony_ci| 8300002 | Operation failed. Cannot connect to service. | 502e41f4b71Sopenharmony_ci| 8300003 | System internal error. | 503e41f4b71Sopenharmony_ci| 8300999 | Unknown error code. | 504e41f4b71Sopenharmony_ci 505e41f4b71Sopenharmony_ci**Example** 506e41f4b71Sopenharmony_ci 507e41f4b71Sopenharmony_ci```ts 508e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 509e41f4b71Sopenharmony_ci 510e41f4b71Sopenharmony_cilet options: call.EmergencyNumberOptions = {slotId: 1} 511e41f4b71Sopenharmony_cicall.isEmergencyPhoneNumber("112", options, (err: BusinessError, data: boolean) => { 512e41f4b71Sopenharmony_ci if (err) { 513e41f4b71Sopenharmony_ci console.error(`isEmergencyPhoneNumber fail, err->${JSON.stringify(err)}`); 514e41f4b71Sopenharmony_ci } else { 515e41f4b71Sopenharmony_ci console.log(`isEmergencyPhoneNumber success, data->${JSON.stringify(data)}`); 516e41f4b71Sopenharmony_ci } 517e41f4b71Sopenharmony_ci}); 518e41f4b71Sopenharmony_ci``` 519e41f4b71Sopenharmony_ci 520e41f4b71Sopenharmony_ci 521e41f4b71Sopenharmony_ci## call.isEmergencyPhoneNumber<sup>7+</sup> 522e41f4b71Sopenharmony_ci 523e41f4b71Sopenharmony_ciisEmergencyPhoneNumber\(phoneNumber: string, options?: EmergencyNumberOptions\): Promise\<boolean\> 524e41f4b71Sopenharmony_ci 525e41f4b71Sopenharmony_ciChecks whether the called number is an emergency number based on the phone number. This API uses a promise to return the result. 526e41f4b71Sopenharmony_ci 527e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Telephony.CallManager 528e41f4b71Sopenharmony_ci 529e41f4b71Sopenharmony_ci**Parameters** 530e41f4b71Sopenharmony_ci 531e41f4b71Sopenharmony_ci| Name | Type | Mandatory| Description | 532e41f4b71Sopenharmony_ci| ----------- | -------------------------------------------------- | ---- | -------------- | 533e41f4b71Sopenharmony_ci| phoneNumber | string | Yes | Phone number. | 534e41f4b71Sopenharmony_ci| options | [EmergencyNumberOptions](#emergencynumberoptions7) | No | Emergency number options.| 535e41f4b71Sopenharmony_ci 536e41f4b71Sopenharmony_ci**Return value** 537e41f4b71Sopenharmony_ci 538e41f4b71Sopenharmony_ci| Type | Description | 539e41f4b71Sopenharmony_ci| ---------------------- | --------------------------------------------------- | 540e41f4b71Sopenharmony_ci| Promise<boolean> | Promise used to return the result. The value **true** indicates that the called number is an emergency number, and the value **false** indicates the opposite.| 541e41f4b71Sopenharmony_ci 542e41f4b71Sopenharmony_ci**Error codes** 543e41f4b71Sopenharmony_ci 544e41f4b71Sopenharmony_ciFor details about the error codes, see [ohos.telephony (Telephony) Error Codes](errorcode-telephony.md) and [Universal Error Codes](../errorcode-universal.md). 545e41f4b71Sopenharmony_ci 546e41f4b71Sopenharmony_ci| ID| Error Message | 547e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- | 548e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2. Incorrect parameters types;| 549e41f4b71Sopenharmony_ci| 8300001 | Invalid parameter value. | 550e41f4b71Sopenharmony_ci| 8300002 | Operation failed. Cannot connect to service. | 551e41f4b71Sopenharmony_ci| 8300003 | System internal error. | 552e41f4b71Sopenharmony_ci| 8300999 | Unknown error code. | 553e41f4b71Sopenharmony_ci 554e41f4b71Sopenharmony_ci**Example** 555e41f4b71Sopenharmony_ci 556e41f4b71Sopenharmony_ci```ts 557e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 558e41f4b71Sopenharmony_ci 559e41f4b71Sopenharmony_cilet options: call.EmergencyNumberOptions = {slotId: 1} 560e41f4b71Sopenharmony_cicall.isEmergencyPhoneNumber("138xxxxxxxx", options).then((data: boolean) => { 561e41f4b71Sopenharmony_ci console.log(`isEmergencyPhoneNumber success, promise: data->${JSON.stringify(data)}`); 562e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => { 563e41f4b71Sopenharmony_ci console.error(`isEmergencyPhoneNumber fail, promise: err->${JSON.stringify(err)}`); 564e41f4b71Sopenharmony_ci}); 565e41f4b71Sopenharmony_ci``` 566e41f4b71Sopenharmony_ci 567e41f4b71Sopenharmony_ci## call.formatPhoneNumber<sup>7+</sup> 568e41f4b71Sopenharmony_ci 569e41f4b71Sopenharmony_ciformatPhoneNumber\(phoneNumber: string, callback: AsyncCallback\<string\>\): void 570e41f4b71Sopenharmony_ci 571e41f4b71Sopenharmony_ciFormats a phone number. This API uses an asynchronous callback to return the result. 572e41f4b71Sopenharmony_ci 573e41f4b71Sopenharmony_ciA formatted phone number is a standard numeric string, for example, 555 0100. 574e41f4b71Sopenharmony_ci 575e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Telephony.CallManager 576e41f4b71Sopenharmony_ci 577e41f4b71Sopenharmony_ci**Parameters** 578e41f4b71Sopenharmony_ci 579e41f4b71Sopenharmony_ci| Name | Type | Mandatory| Description | 580e41f4b71Sopenharmony_ci| ----------- | --------------------------- | ---- | ------------------------------------ | 581e41f4b71Sopenharmony_ci| phoneNumber | string | Yes | Phone number. | 582e41f4b71Sopenharmony_ci| callback | AsyncCallback<string> | Yes | Callback used to return the result.| 583e41f4b71Sopenharmony_ci 584e41f4b71Sopenharmony_ci**Error codes** 585e41f4b71Sopenharmony_ci 586e41f4b71Sopenharmony_ciFor details about the error codes, see [ohos.telephony (Telephony) Error Codes](errorcode-telephony.md) and [Universal Error Codes](../errorcode-universal.md). 587e41f4b71Sopenharmony_ci 588e41f4b71Sopenharmony_ci| ID| Error Message | 589e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- | 590e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2. Incorrect parameters types;| 591e41f4b71Sopenharmony_ci| 8300001 | Invalid parameter value. | 592e41f4b71Sopenharmony_ci| 8300002 | Operation failed. Cannot connect to service. | 593e41f4b71Sopenharmony_ci| 8300003 | System internal error. | 594e41f4b71Sopenharmony_ci| 8300999 | Unknown error code. | 595e41f4b71Sopenharmony_ci 596e41f4b71Sopenharmony_ci**Example** 597e41f4b71Sopenharmony_ci 598e41f4b71Sopenharmony_ci```ts 599e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 600e41f4b71Sopenharmony_ci 601e41f4b71Sopenharmony_cicall.formatPhoneNumber("138xxxxxxxx", (err: BusinessError, data: string) => { 602e41f4b71Sopenharmony_ci if (err) { 603e41f4b71Sopenharmony_ci console.error(`formatPhoneNumber fail, err->${JSON.stringify(err)}`); 604e41f4b71Sopenharmony_ci } else { 605e41f4b71Sopenharmony_ci console.log(`formatPhoneNumber success, data->${JSON.stringify(data)}`); 606e41f4b71Sopenharmony_ci } 607e41f4b71Sopenharmony_ci}); 608e41f4b71Sopenharmony_ci``` 609e41f4b71Sopenharmony_ci 610e41f4b71Sopenharmony_ci## call.formatPhoneNumber<sup>7+</sup> 611e41f4b71Sopenharmony_ci 612e41f4b71Sopenharmony_ciformatPhoneNumber\(phoneNumber: string, options: NumberFormatOptions, callback: AsyncCallback\<string\>\): void 613e41f4b71Sopenharmony_ci 614e41f4b71Sopenharmony_ciFormats a phone number based on specified formatting options. This API uses an asynchronous callback to return the result. 615e41f4b71Sopenharmony_ci 616e41f4b71Sopenharmony_ciA formatted phone number is a standard numeric string, for example, 555 0100. 617e41f4b71Sopenharmony_ci 618e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Telephony.CallManager 619e41f4b71Sopenharmony_ci 620e41f4b71Sopenharmony_ci**Parameters** 621e41f4b71Sopenharmony_ci 622e41f4b71Sopenharmony_ci| Name | Type | Mandatory| Description | 623e41f4b71Sopenharmony_ci| ----------- | -------------------------------------------- | ---- | ------------------------------------ | 624e41f4b71Sopenharmony_ci| phoneNumber | string | Yes | Phone number. | 625e41f4b71Sopenharmony_ci| options | [NumberFormatOptions](#numberformatoptions7) | Yes | Number formatting options, for example, country code. | 626e41f4b71Sopenharmony_ci| callback | AsyncCallback<string> | Yes | Callback used to return the result.| 627e41f4b71Sopenharmony_ci 628e41f4b71Sopenharmony_ci**Error codes** 629e41f4b71Sopenharmony_ci 630e41f4b71Sopenharmony_ciFor details about the error codes, see [ohos.telephony (Telephony) Error Codes](errorcode-telephony.md) and [Universal Error Codes](../errorcode-universal.md). 631e41f4b71Sopenharmony_ci 632e41f4b71Sopenharmony_ci| ID| Error Message | 633e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- | 634e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2. Incorrect parameters types;| 635e41f4b71Sopenharmony_ci| 8300001 | Invalid parameter value. | 636e41f4b71Sopenharmony_ci| 8300002 | Operation failed. Cannot connect to service. | 637e41f4b71Sopenharmony_ci| 8300003 | System internal error. | 638e41f4b71Sopenharmony_ci| 8300999 | Unknown error code. | 639e41f4b71Sopenharmony_ci 640e41f4b71Sopenharmony_ci**Example** 641e41f4b71Sopenharmony_ci 642e41f4b71Sopenharmony_ci```ts 643e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 644e41f4b71Sopenharmony_ci 645e41f4b71Sopenharmony_cilet options: call.NumberFormatOptions = { 646e41f4b71Sopenharmony_ci countryCode: "CN" 647e41f4b71Sopenharmony_ci} 648e41f4b71Sopenharmony_cicall.formatPhoneNumber("138xxxxxxxx", options, (err: BusinessError, data: string) => { 649e41f4b71Sopenharmony_ci if (err) { 650e41f4b71Sopenharmony_ci console.error(`formatPhoneNumber fail, err->${JSON.stringify(err)}`); 651e41f4b71Sopenharmony_ci } else { 652e41f4b71Sopenharmony_ci console.log(`formatPhoneNumber success, data->${JSON.stringify(data)}`); 653e41f4b71Sopenharmony_ci } 654e41f4b71Sopenharmony_ci}); 655e41f4b71Sopenharmony_ci``` 656e41f4b71Sopenharmony_ci 657e41f4b71Sopenharmony_ci 658e41f4b71Sopenharmony_ci## call.formatPhoneNumber<sup>7+</sup> 659e41f4b71Sopenharmony_ci 660e41f4b71Sopenharmony_ciformatPhoneNumber\(phoneNumber: string, options?: NumberFormatOptions\): Promise\<string\> 661e41f4b71Sopenharmony_ci 662e41f4b71Sopenharmony_ciFormats a phone number based on specified formatting options. This API uses a promise to return the result. 663e41f4b71Sopenharmony_ci 664e41f4b71Sopenharmony_ciA formatted phone number is a standard numeric string, for example, 555 0100. 665e41f4b71Sopenharmony_ci 666e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Telephony.CallManager 667e41f4b71Sopenharmony_ci 668e41f4b71Sopenharmony_ci**Parameters** 669e41f4b71Sopenharmony_ci 670e41f4b71Sopenharmony_ci| Name | Type | Mandatory| Description | 671e41f4b71Sopenharmony_ci| ----------- | -------------------------------------------- | ---- | ---------------------- | 672e41f4b71Sopenharmony_ci| phoneNumber | string | Yes | Phone number. | 673e41f4b71Sopenharmony_ci| options | [NumberFormatOptions](#numberformatoptions7) | No | Number formatting options, for example, country code.| 674e41f4b71Sopenharmony_ci 675e41f4b71Sopenharmony_ci**Return value** 676e41f4b71Sopenharmony_ci 677e41f4b71Sopenharmony_ci| Type | Description | 678e41f4b71Sopenharmony_ci| --------------------- | ------------------------------------------- | 679e41f4b71Sopenharmony_ci| Promise<string> | Promise used to return the result.| 680e41f4b71Sopenharmony_ci 681e41f4b71Sopenharmony_ci**Error codes** 682e41f4b71Sopenharmony_ci 683e41f4b71Sopenharmony_ciFor details about the error codes, see [ohos.telephony (Telephony) Error Codes](errorcode-telephony.md) and [Universal Error Codes](../errorcode-universal.md). 684e41f4b71Sopenharmony_ci 685e41f4b71Sopenharmony_ci| ID| Error Message | 686e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- | 687e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2. Incorrect parameters types;| 688e41f4b71Sopenharmony_ci| 8300001 | Invalid parameter value. | 689e41f4b71Sopenharmony_ci| 8300002 | Operation failed. Cannot connect to service. | 690e41f4b71Sopenharmony_ci| 8300003 | System internal error. | 691e41f4b71Sopenharmony_ci| 8300999 | Unknown error code. | 692e41f4b71Sopenharmony_ci 693e41f4b71Sopenharmony_ci**Example** 694e41f4b71Sopenharmony_ci 695e41f4b71Sopenharmony_ci```ts 696e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 697e41f4b71Sopenharmony_ci 698e41f4b71Sopenharmony_cilet options: call.NumberFormatOptions = { 699e41f4b71Sopenharmony_ci countryCode: "CN" 700e41f4b71Sopenharmony_ci} 701e41f4b71Sopenharmony_cicall.formatPhoneNumber("138xxxxxxxx", options).then((data: string) => { 702e41f4b71Sopenharmony_ci console.log(`formatPhoneNumber success, promise: data->${JSON.stringify(data)}`); 703e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => { 704e41f4b71Sopenharmony_ci console.error(`formatPhoneNumber fail, promise: err->${JSON.stringify(err)}`); 705e41f4b71Sopenharmony_ci}); 706e41f4b71Sopenharmony_ci``` 707e41f4b71Sopenharmony_ci 708e41f4b71Sopenharmony_ci## call.formatPhoneNumberToE164<sup>7+</sup> 709e41f4b71Sopenharmony_ci 710e41f4b71Sopenharmony_ciformatPhoneNumberToE164\(phoneNumber: string, countryCode: string, callback: AsyncCallback\<string\>\): void 711e41f4b71Sopenharmony_ci 712e41f4b71Sopenharmony_ciConverts a phone number into the E.164 format. This API uses an asynchronous callback to return the result. 713e41f4b71Sopenharmony_ci 714e41f4b71Sopenharmony_ciThe phone number must match the specified country code. For example, for a China phone number, the country code must be **CN**. Otherwise, **null** will be returned. 715e41f4b71Sopenharmony_ci 716e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Telephony.CallManager 717e41f4b71Sopenharmony_ci 718e41f4b71Sopenharmony_ci**Parameters** 719e41f4b71Sopenharmony_ci 720e41f4b71Sopenharmony_ci| Name | Type | Mandatory| Description | 721e41f4b71Sopenharmony_ci| ----------- | --------------------------- | ---- | ----------------------------------------------------- | 722e41f4b71Sopenharmony_ci| phoneNumber | string | Yes | Phone number. | 723e41f4b71Sopenharmony_ci| countryCode | string | Yes | Country code, for example, **CN** (China). All country codes are supported. | 724e41f4b71Sopenharmony_ci| callback | AsyncCallback<string> | Yes | Callback used to return the result.| 725e41f4b71Sopenharmony_ci 726e41f4b71Sopenharmony_ci**Error codes** 727e41f4b71Sopenharmony_ci 728e41f4b71Sopenharmony_ciFor details about the error codes, see [ohos.telephony (Telephony) Error Codes](errorcode-telephony.md) and [Universal Error Codes](../errorcode-universal.md). 729e41f4b71Sopenharmony_ci 730e41f4b71Sopenharmony_ci| ID| Error Message | 731e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- | 732e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2. Incorrect parameters types;| 733e41f4b71Sopenharmony_ci| 8300001 | Invalid parameter value. | 734e41f4b71Sopenharmony_ci| 8300002 | Operation failed. Cannot connect to service. | 735e41f4b71Sopenharmony_ci| 8300003 | System internal error. | 736e41f4b71Sopenharmony_ci| 8300999 | Unknown error code. | 737e41f4b71Sopenharmony_ci 738e41f4b71Sopenharmony_ci**Example** 739e41f4b71Sopenharmony_ci 740e41f4b71Sopenharmony_ci```ts 741e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 742e41f4b71Sopenharmony_ci 743e41f4b71Sopenharmony_cicall.formatPhoneNumberToE164("138xxxxxxxx", "CN", (err: BusinessError, data: string) => { 744e41f4b71Sopenharmony_ci if (err) { 745e41f4b71Sopenharmony_ci console.error(`formatPhoneNumberToE164 fail, err->${JSON.stringify(err)}`); 746e41f4b71Sopenharmony_ci } else { 747e41f4b71Sopenharmony_ci console.log(`formatPhoneNumberToE164 success, data->${JSON.stringify(data)}`); 748e41f4b71Sopenharmony_ci } 749e41f4b71Sopenharmony_ci}); 750e41f4b71Sopenharmony_ci``` 751e41f4b71Sopenharmony_ci 752e41f4b71Sopenharmony_ci 753e41f4b71Sopenharmony_ci## call.formatPhoneNumberToE164<sup>7+</sup> 754e41f4b71Sopenharmony_ci 755e41f4b71Sopenharmony_ciformatPhoneNumberToE164\(phoneNumber: string, countryCode: string\): Promise\<string\> 756e41f4b71Sopenharmony_ci 757e41f4b71Sopenharmony_ciConverts a phone number into the E.164 format. This API uses a promise to return the result. 758e41f4b71Sopenharmony_ci 759e41f4b71Sopenharmony_ciThe phone number must match the specified country code. For example, for a China phone number, the country code must be **CN**. Otherwise, **null** will be returned. 760e41f4b71Sopenharmony_ci 761e41f4b71Sopenharmony_ciAll country codes are supported. 762e41f4b71Sopenharmony_ci 763e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Telephony.CallManager 764e41f4b71Sopenharmony_ci 765e41f4b71Sopenharmony_ci**Parameters** 766e41f4b71Sopenharmony_ci 767e41f4b71Sopenharmony_ci| Name | Type | Mandatory| Description | 768e41f4b71Sopenharmony_ci| ----------- | ------ | ---- | ---------------------------------------- | 769e41f4b71Sopenharmony_ci| phoneNumber | string | Yes | Phone number. | 770e41f4b71Sopenharmony_ci| countryCode | string | Yes | Country code, for example, **CN** (China). All country codes are supported.| 771e41f4b71Sopenharmony_ci 772e41f4b71Sopenharmony_ci**Return value** 773e41f4b71Sopenharmony_ci 774e41f4b71Sopenharmony_ci| Type | Description | 775e41f4b71Sopenharmony_ci| --------------------- | ------------------------------------------------------------ | 776e41f4b71Sopenharmony_ci| Promise<string> | Promise used to return the result.| 777e41f4b71Sopenharmony_ci 778e41f4b71Sopenharmony_ci**Error codes** 779e41f4b71Sopenharmony_ci 780e41f4b71Sopenharmony_ciFor details about the error codes, see [ohos.telephony (Telephony) Error Codes](errorcode-telephony.md) and [Universal Error Codes](../errorcode-universal.md). 781e41f4b71Sopenharmony_ci 782e41f4b71Sopenharmony_ci| ID| Error Message | 783e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- | 784e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2. Incorrect parameters types;| 785e41f4b71Sopenharmony_ci| 8300001 | Invalid parameter value. | 786e41f4b71Sopenharmony_ci| 8300002 | Operation failed. Cannot connect to service. | 787e41f4b71Sopenharmony_ci| 8300003 | System internal error. | 788e41f4b71Sopenharmony_ci| 8300999 | Unknown error code. | 789e41f4b71Sopenharmony_ci 790e41f4b71Sopenharmony_ci**Example** 791e41f4b71Sopenharmony_ci 792e41f4b71Sopenharmony_ci```ts 793e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 794e41f4b71Sopenharmony_ci 795e41f4b71Sopenharmony_cicall.formatPhoneNumberToE164("138xxxxxxxx", "CN").then((data: string) => { 796e41f4b71Sopenharmony_ci console.log(`formatPhoneNumberToE164 success, promise: data->${JSON.stringify(data)}`); 797e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => { 798e41f4b71Sopenharmony_ci console.error(`formatPhoneNumberToE164 fail, promise: err->${JSON.stringify(err)}`); 799e41f4b71Sopenharmony_ci}); 800e41f4b71Sopenharmony_ci``` 801e41f4b71Sopenharmony_ci 802e41f4b71Sopenharmony_ci## DialOptions 803e41f4b71Sopenharmony_ci 804e41f4b71Sopenharmony_ciProvides an option for determining whether a call is a video call. 805e41f4b71Sopenharmony_ci 806e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Telephony.CallManager 807e41f4b71Sopenharmony_ci 808e41f4b71Sopenharmony_ci| Name | Type | Mandatory| Description | 809e41f4b71Sopenharmony_ci| ------------------------ | ---------------------------------- | ---- | ----------------------------------------------------------------------------------------------- | 810e41f4b71Sopenharmony_ci| extras | boolean | No | Whether the call is a video call. <br>- **true**: video call<br>- **false** (default): voice call | 811e41f4b71Sopenharmony_ci 812e41f4b71Sopenharmony_ci## CallState 813e41f4b71Sopenharmony_ci 814e41f4b71Sopenharmony_ciEnumerates call states. 815e41f4b71Sopenharmony_ci 816e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Telephony.CallManager 817e41f4b71Sopenharmony_ci 818e41f4b71Sopenharmony_ci| Name | Value | Description | 819e41f4b71Sopenharmony_ci| ------------------ | ---- | ------------------------------------------------------------ | 820e41f4b71Sopenharmony_ci| CALL_STATE_UNKNOWN | -1 | The call status fails to be obtained and is unknown. | 821e41f4b71Sopenharmony_ci| CALL_STATE_IDLE | 0 | No call is in progress. | 822e41f4b71Sopenharmony_ci| CALL_STATE_RINGING | 1 | The call is in the ringing or waiting state. | 823e41f4b71Sopenharmony_ci| CALL_STATE_OFFHOOK | 2 | At least one call is in dialing, active, or on hold, and no new incoming call is ringing or waiting.| 824e41f4b71Sopenharmony_ci| CALL_STATE_ANSWERED<sup>11+</sup> | 3 | The incoming call is answered.| 825e41f4b71Sopenharmony_ci 826e41f4b71Sopenharmony_ci## EmergencyNumberOptions<sup>7+</sup> 827e41f4b71Sopenharmony_ci 828e41f4b71Sopenharmony_ciProvides an option for determining whether a number is an emergency number for the SIM card in the specified slot. 829e41f4b71Sopenharmony_ci 830e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Telephony.CallManager 831e41f4b71Sopenharmony_ci 832e41f4b71Sopenharmony_ci| Name | Type | Mandatory| Description | 833e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ---------------------------------------------- | 834e41f4b71Sopenharmony_ci| slotId | number | No | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2| 835e41f4b71Sopenharmony_ci 836e41f4b71Sopenharmony_ci## NumberFormatOptions<sup>7+</sup> 837e41f4b71Sopenharmony_ci 838e41f4b71Sopenharmony_ciProvides an option for number formatting. 839e41f4b71Sopenharmony_ci 840e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Telephony.CallManager 841e41f4b71Sopenharmony_ci 842e41f4b71Sopenharmony_ci| Name | Type | Mandatory| Description | 843e41f4b71Sopenharmony_ci| ----------- | ------ | ---- | ---------------------------------------------------------- | 844e41f4b71Sopenharmony_ci| countryCode | string | No | Country code, for example, **CN** (China). All country codes are supported. The default value is **CN**.| 845