鸿蒙 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;

})

}

}

}

直接用就好啦

相关推荐
UnicornDev10 小时前
【Flutter x HarmonyOS 6】挑战功能的业务逻辑实现
flutter·华为·harmonyos·鸿蒙·鸿蒙系统
心疼你的一切2 天前
从零到一:鸿蒙健康监测应用的全流程开发实录
人工智能·华为·harmonyos·鸿蒙·鸿蒙系统
梦想不只是梦与想3 天前
鸿蒙与 H5 通信使用的方法及原理
harmonyos·鸿蒙·webview
阿钱真强道3 天前
22 鸿蒙LiteOS 互斥锁(Mutex)实战教程:多任务共享资源保护
harmonyos·鸿蒙·互斥·rk·liteos·瑞芯微·rk2206
坚果派·白晓明4 天前
【鸿蒙PC三方库移植适配框架解读系列】第八篇:扩展lycium框架使其满足rust三方库适配
c语言·开发语言·华为·rust·harmonyos·鸿蒙
坚果派·白晓明4 天前
【鸿蒙PC三方库移植适配框架解读系列】第五篇:完整流程图与角色职责
c语言·c++·华为·harmonyos·鸿蒙
KillerNoBlood4 天前
2026移动端跨平台开发面经总结
android·算法·flutter·ios·移动开发·鸿蒙·kmp
unique_williams4 天前
开源 | 我用 HarmonyOS + Spring Boot 写了一个全栈背单词 App,已上架 GitHub
springboot·鸿蒙
三声三视4 天前
Electron + 鸿蒙分布式投屏:PC 端一键推送画面到鸿蒙设备全实战
分布式·electron·harmonyos·鸿蒙·桌面
UnicornDev4 天前
【Flutter x HarmonyOS 6】魔方计时APP——挑战页面的UI设计
flutter·ui·华为·harmonyos·鸿蒙