HarmonyOS 鸿蒙Next 调用浏览器打开网址报错“暂无支持此类文件的应用”

HarmonyOS 鸿蒙Next 调用浏览器打开网址报错“暂无支持此类文件的应用”

按照文档要求,使用隐式Want打开浏览器。报错“暂无支持此类文件的应用”


调用方式:
/**
* 打开浏览器
* @param url
*/
startBrowser(context: Context, url: string) {
let uiContext = context as common.UIAbilityContext
let wantInfo: Want = {
action: ‘ohos.want.action.viewData’,
entities: [‘entity.system.browsable’],
uri: url
}
uiContext.startAbility(wantInfo).then(() => {
// do nothing…
}).catch((err: BusinessError) => {
// do nothing…
})
}

配置文件:
“skills”: [
{
“entities”: [
“entity.system.home”,
“entity.system.browsable” // 浏览器打开
],
“actions”: [
“action.system.home”,
“ohos.want.action.viewData” // 浏览器打开
]
}
]


 


更多关于HarmonyOS 鸿蒙Next 调用浏览器打开网址报错“暂无支持此类文件的应用”的实战教程也可以访问 https://www.itying.com/category-93-b0.html

2 回复

兄弟,你的module.json5文件有问题,没有uris参数。可以参考一下demo:

module.json5文件中的skills:

     "skills": [
          {
            "entities": [
              "entity.system.home",
              "entity.system.browsable"
            ],
            "actions": [
              "action.system.home",
              "ohos.want.action.viewData"
            ],
            "uris": [
              {
                "scheme": "https",
                "host": "www.baidu.com",
                "port": "8080",
                // prefix matching
                "pathStartWith": "query",
              }
            ]
          }
        ]

index文件

import common from '[@ohos](/user/ohos).app.ability.common';
import Want from '[@ohos](/user/ohos).app.ability.Want';
import { BusinessError } from '[@ohos](/user/ohos).base';
import process from '[@ohos](/user/ohos).process';


let context = getContext(this) as common.UIAbilityContext;
let wantInfo: Want = {

  "action": 'ohos.want.action.viewData',
  "entities": ['entity.system.browsable'],
  "uri": "https://www.baidu.com",
}


[@Entry](/user/Entry)
[@Component](/user/Component)
struct Index {
  [@State](/user/State) message: string = '跳转百度';

  aboutToAppear(): void {
    console.log("child-testTAG", `${process.tid}`)
  }

  build() {
    Row() {
      Column() {
        Text(this.message)
          .fontSize(50)
          .fontWeight(FontWeight.Bold)
          .onClick(async () => {
            context.startAbility(wantInfo).then(() => {
              // ...
            }).catch((err: BusinessError) => {
              // ...
            })
          })
      }
      .width('100%')
    }
    .height('100%')
  }
}
 
	<p><span>参考文档:‘<a class="autoSetLinkTag" href="https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V13/explicit-implicit-want-mappings-V13" target="_blank">https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V13/explicit-implicit-want-mappings-V13</a>’</span></p>  <p></p>  <p>匹配过程分析:<br> <br> 调用方传入的want参数的action不为空,待匹配目标应用组件的skills配置中的actions不为空且包含调用方传入的want参数的action,action匹配成功。<br> 调用方传入的want参数的entities不为空,待匹配目标应用组件的skills配置中的entities不为空且包含调用方传入的want参数的entities,entities匹配成功。<br><span> 待匹配目标应用组件的skills配置中内uris拼接为<a class="autoSetLinkTag" href="https://www.test.com:8080/query" target="_blank" rel="nofollow">https://www.test.com:8080/query</a>*(其中*表示通配符),包含调用方传入的want参数的uri,uri匹配成功。</span></p> 

更多关于HarmonyOS 鸿蒙Next 调用浏览器打开网址报错“暂无支持此类文件的应用”的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html


针对HarmonyOS鸿蒙Next调用浏览器打开网址报错“暂无支持此类文件的应用”的问题,这通常是由于JumpParams或Want配置不正确导致的。

首先,确保你使用的action是正确的。在HarmonyOS中,打开浏览器通常使用的action是ohos.want.action.viewData,但具体支持的action可能依赖于HarmonyOS的版本和设备的具体实现。如果ohos.want.action.viewData不起作用,可以尝试查阅HarmonyOS的官方文档,确认是否有其他特定的action用于打开浏览器。

其次,检查URI格式是否正确,确保它是一个有效的HTTP或HTTPS链接。

最后,检查是否在module.json5配置文件中进行了正确的配置。确保skills部分包含了正确的entities和actions,以及可能的uris配置。

如果以上步骤都正确无误,但问题依旧存在,那么可能是系统或设备的问题。此时,建议联系设备制造商或查看HarmonyOS的开发者论坛获取更具体的帮助。如果问题依旧没法解决请联系官网客服,官网地址是:https://www.itying.com/category-93-b0.html

回到顶部