【关键字】
跳转 / 拨号界面 / 传入 / 拨打号码
【问题描述】
如何跳转系统拨号界面并传入要拨打的号码?
【解决方案】
示例代码如下:
import call from '@ohos.telephony.call';
import { BusinessError } from '@ohos.base';
function startCallDialog(): void {
let isSupport = call.hasVoiceCapability();
if (!isSupport) {
console.error('Not support voice capability.');
return;
}
call.makeCall('16888888888', (err: BusinessError) => {
if (err) {
console.error(`Failed to make call. Code is ${err.code}, Message is ${err.message}`);
return;
}
console.info('Succeeded in making call.');
})
}
@Entry
@Component
struct Phone {
build() {
Row() {
Column() {
Button('拨打电话')
.onClick(() => {
startCallDialog();
})
}
.width('100%')
}
.height('100%')
}
}