当前位置: 首页> 健康> 科研 > 甘肃省疫情防控最新消息_遵义网站建设公司排名_seo培训班_发软文的平台

甘肃省疫情防控最新消息_遵义网站建设公司排名_seo培训班_发软文的平台

时间:2025/8/23 2:48:57来源:https://blog.csdn.net/HUAWEI_HMSCore/article/details/144023570 浏览次数:0次
甘肃省疫情防控最新消息_遵义网站建设公司排名_seo培训班_发软文的平台

1.问题描述:

文档哪里能找到所有的权限查看该权限是用户级的还是系统级的。

解决方案:

您好,可以看一下下方链接是否可以解决问题:

https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/permissions-for-all-V5

https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/permissions-in-acl-V5

2.问题描述:

查阅文档发现isApplicationEnabled方法已被弃用,目前如何判断手机中某个应用是否已安装?

解决方案:

应用是否已安装?

目前判断应用是否在手机安装,在API 12之前并不支持。

在API 12之后,bundleManager支持canOpenLink接口,通过配置module.json5的querySchemes属性,在代码中可以通过一下代码确定对应应用是否安装:

参考链接:https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/js-apis-bundlemanager-V5#ZH-CN_TOPIC_0000001893370881__bundlemanagercanopenlink12

3.问题描述:

如何在代码中获取oh-package.json5中的信息,比如版本(version)或者描述(description)?

解决方案:

可以通过hvigor脚本实现。

hvigor自定义任务指导:https://developer.harmonyos.com/cn/docs/documentation/doc-guides-V2/custom-hvigor-0000001650987753-V2

hvigor命令行指导:https://developer.harmonyos.com/cn/docs/documentation/doc-guides-V2/ide-command-line-hvigor-0000001553317645-V2

Demo: 这里展示在har module的hvigorfile.ts文件下,编写脚本代码,实现: 1.获取并解析oh-package.json5中的内容 2.获取har产物的路径 3.修改har产物的名称


import { harTasks } from '@ohos/hvigor-ohos-plugin';import fs from 'fs'interface OhPackage {name: string;version: number;description: string;author: string;}export function renameHarTask(str?: string) {return {pluginId: 'RenameHarTaskID',apply(pluginContext) {pluginContext.registerTask({// 编写自定义任务name: 'renameHarTask',run: (taskContext) => {//读取oh-package.json5,解析出versionconst packageFile = taskContext.modulePath+'\oh-package.json5';console.log('file: ', packageFile);let fileContent = fs.readFileSync(packageFile, 'utf8');console.log(fileContent);const content: OhPackage = JSON.parse(fileContent);const version = content.version;const author = content.author;console.log('renameHarTask: ', taskContext.moduleName, taskContext.modulePath);const sourceFile = taskContext.modulePath + '\\build\\default\\outputs\\default\\' + taskContext.moduleName + '.har';const targetFile = taskContext.modulePath + '\\build\\default\\outputs\\default\\'+ taskContext.moduleName + '-' + version + '-' + author +'.har';console.log('renameHarTask: sourceFile: ', sourceFile);console.log('renameHarTask: targetFile: ', targetFile);// 修改产物名fs.rename(sourceFile, targetFile, (err)=> {console.log('err: ' + err);});},// 确认自定义任务插入位置dependencies: ['default@PackageHar'],postDependencies: ['assembleHar']})}}}export default {system: harTasks,plugins:[renameHarTask()]}

实现效果 在Terminal窗口执行: ./hvigorw renameHarTask 查看build/default/outputs/default/下的har,可以看到,生成的har已经修改为了我们代码中指定的taskContext.moduleName + ‘-’ + version + ‘-’ + author +‘.har’

4.问题描述:

编译报错:The default system capabilities of devices phone, tablet, 2in1 do not include SystemCapability.Communication.NFC.Tag. Configure the capabilities in syscap.json.

解决方案:

报错提示是:不包括SystemCapability.Communication.NFC.Tag,需要syscap.json中配置。

可参考链接:https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/syscap-V5#ZH-CN_TOPIC_0000001904100062__pcid%E5%AF%BC%E5%85%A5

关键字:甘肃省疫情防控最新消息_遵义网站建设公司排名_seo培训班_发软文的平台

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

责任编辑: