使用hdc命令拉起hipreview应用并传入本地文件直接预览失败。
hdc shell aa start -b com.huawei.hmos.hipreview -a MainAbility -U file://storage/media/100/local/files/Docs/Documents/1.pdf
其中文件路径是通过Device File Browser获取的文件真实路径,也叫物理路径。

命令行执行效果预览:

-U参数传递错误,-U参数对应的是URI参数,而不是文件物理路径。
hdc shell aa start -b com.huawei.hmos.hipreview -a MainAbility -U file://docs/storage/Users/currentUser/Documents/1.pdf

Q:aa命令传入URI参数(-U)为文件的物理路径预览失败。
A:URI参数(-U)对应的是URI的类型。
Q:aa命令中-U参数携带query参数,但query参数丢失,命令如下:
hdc shell aa start -a MainAbility -b {bundleName} -A ohos.want.action.viewData -U "url?param1=v1¶m2=v2"
A:参数丢失是因为hdc shell会去掉最外层双引号,shell读到&时会当做特殊字符,后面的参数不能透传,正确的写法是:
hdc shell aa "start -a MainAbility -b xxx -A ohos.want.action.viewData -U 'url?param1=v1¶m2=v2'"
Q:aa start命令行拉起app,-U命令后跟的URI解析成want中的URI参数丢失,命令如下:
hdc shell aa start -A action.system.home -U 'miguvideo://miguvideotv?action={"params":{"extra":{"detail_type":"JUMP_NEW_PAY_PAGE","deepLinkType":"launch er"},"pageID":"98ab1e76e24c4472a9018408ca0087f4"},"type":"JUMP_INNER_NEW_PAGE"}'
A:传参方式不正确,参考官网文档aa工具启动命令(start),可尝试换成下面这种传参方式:
aa start -U myscheme://www.test.com:8080/path --pi paramNumber 1 --pb paramBoolean true --ps paramString teststring --psn paramNullString