HarmonyOS 想要打开系统自带的浏览器,提示‘暂无支持此类型文件的应用’

代码如下:

let jumpParams: JumpParams = { 
  action: 'ohos.want.action.search', 
  entities: ['entity.system.browsable'], 
  uri: 'http://www.xxxxx.com', 
  type: "text/plain" 
} 
let context = getContext() as common.UIAbilityContext; 
context.startAbility(jumpParams)


HarmonyOS
2024-08-10 12:24:06
浏览
收藏 0
回答 1
待解决
回答 1
按赞同
/
按时间
put_get

检查是否在module.json5配置文件中进行配置,可以参考这个文档:https://developer.huawei.com/consumer/cn/doc/harmonyos-guides/ability-startup-with-implicit-want-0000001820879633

demo如下:

// demo.ets 
import common from '@ohos.app.ability.common'; 
import Want from '@ohos.app.ability.Want'; 
import { BusinessError } from '@ohos.base'; 
 
@Entry 
@Component 
struct  openBrowserTest { 
  build() { 
    Column() { 
      Button('Open Browser') 
        .fontColor(Color.Black) 
        .fontSize(40) 
        .onClick((event) => { 
          let context = getContext(this) as common.UIAbilityContext; 
          let wantInfo: Want = { 
            action: 'ohos.want.action.viewData', 
            // entities can be omitted. 
            entities: ['entity.system.browsable'], 
            uri: 'https://www.xxxxx' 
          } 
          context.startAbility(wantInfo).then(() => { 
            console.debug(`1231111 `) 
            context.terminateSelf(); 
          }).catch((err: BusinessError) => { 
            console.info(`testTag: Failed to startAbility. Error: `+ JSON.stringify(err)) 
          }) 
        }) 
    } 
  } 
}
分享
微博
QQ
微信
回复
2024-08-10 17:48:34
相关问题
HarmonyOS跳转系统浏览器打开网页报错
707浏览 • 1回复 待解决
Web组件是否支持浏览器localstorage?
953浏览 • 1回复 待解决
浏览器下载文件如何导入鸿蒙
7298浏览 • 1回复 待解决
浏览器应用应该怎样拉起?
469浏览 • 2回复 待解决
HarmonyOS applink从浏览器跳转到应用
20浏览 • 1回复 待解决