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)
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.


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)) 
          }) 
        }) 
    } 
  } 
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
分享
微博
QQ
微信
回复
2024-08-10 17:48:34
相关问题
HarmonyOS跳转系统浏览器打开网页报错
1862浏览 • 1回复 待解决
Web组件是否支持浏览器localstorage?
1640浏览 • 1回复 待解决
浏览器下载文件如何导入鸿蒙
8585浏览 • 1回复 待解决
浏览器应用应该怎样拉起?
1205浏览 • 2回复 待解决