harmonyos-next中如何在APP内打开系统浏览器呢?

harmonyos-next中如何在APP内打开系统浏览器呢?

是否支持在app调起系统浏览器,传入要打开的地址,怎么实现呢?

本文参与了思否 HarmonyOS 技术问答马拉松,欢迎正在阅读的你也加入。
阅读 910
1 个回答

在调用方UIAbility中,使用隐式Want方式启动浏览器应用。

import common from '@ohos.app.ability.common';
import Want from '@ohos.app.ability.Want';
import { BusinessError } from '@ohos.base';

let context = getContext(this) as common.UIAbilityContext;
let wantInfo: Want = {
  // uncomment line below if wish to implicitly query only in the specific bundle.
  // bundleName: 'com.example.myapplication',
  action: 'ohos.want.action.viewData',
  // entities can be omitted.
  entities: ['entity.system.browsable'],
  uri: 'https://www.test.com:8080/query/student'
}
context.startAbility(wantInfo).then(() => {
  // ...
}).catch((err: BusinessError) => {
  // ...
})

具体参考官方文档:https://developer.huawei.com/consumer/cn/doc/harmonyos-guides...

本文参与了思否 HarmonyOS 技术问答马拉松,欢迎正在阅读的你也加入。
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进