鸿蒙 H5 拉起手机拨号

// xxx.ets

import { webview } from '@kit.ArkWeb';

import { call } from '@kit.TelephonyKit';

@Entry

@Component

struct WebComponent {

webviewController: webview.WebviewController = new webview.WebviewController();

build() {

Column() {

Web({ src: $rawfile('call.html'), controller: this.webviewController })

.onLoadIntercept((event) => {

if (event) {

let url: string = event.data.getRequestUrl();

// 判断链接是否为拨号链接

if (url.indexOf('tel://') === 0) {

// 跳转拨号界面

call.makeCall(url.substring(6), (err) => {

if (!err) {

console.info('make call succeeded.');

} else {

console.info('make call fail, err is:' + JSON.stringify(err));

}

});

return true;

}

}

return false;

})

}

}

}

直接用就好啦

相关推荐
红烧大青虫4 小时前
HarmonyOS应用《玄象》开发实战:掷钱动画:animateTo + 缓动曲线的物理感模拟
harmonyos·鸿蒙
fengxinzi_zack8 小时前
HarmonyOS应用《玄象》开发实战:MansionListPage 列表页:List / ListItem / LazyForEach 性能优化
harmonyos·鸿蒙
爱写代码的阿森10 小时前
鸿蒙三方库 | harmony-utils之RegexUtil正则匹配验证详解
服务器·华为·harmonyos·鸿蒙·huawei
echohelloworld1110 小时前
HarmonyOS应用《玄象》开发实战:项目目录约定:common/components/constants/utils/pages 六层架构
harmonyos·鸿蒙
熊猫钓鱼>_>11 小时前
2026 鸿蒙全栈开发实战:从新能力落地到多设备上架的完整路径
华为·架构·app·harmonyos·arkts·鸿蒙·运营
FF2501_9402285812 小时前
HarmonyOS应用《玄象》开发实战:罗盘手势缩放:PinchGesture + scale 属性的协同
harmonyos·鸿蒙
fengxinzi_zack13 小时前
HarmonyOS应用《玄象》开发实战:@State fadeOpacity 淡入动画与 animation curve
harmonyos·鸿蒙
b1305381004913 小时前
HarmonyOS应用《玄象》开发实战:命盘排布 Canvas:四柱干支 + 六十甲子纳音表的同步绘制
harmonyos·鸿蒙
爱写代码的阿森13 小时前
鸿蒙三方库 | harmony-utils之ArrayUtil集合过滤排序与分块详解
华为·harmonyos·鸿蒙·huawei
LEO1111014 小时前
HarmonyOS应用《玄象》开发实战:RenderingContextSettings(true) 抗锯齿对 Canvas 渲染的影响
harmonyos·鸿蒙