codecamp

鸿蒙OS 配置文件示例

以 JSON 文件为 config.json 的一个简单示例,该示例的应用声明为三个 Ability。

{
    "app": {
        "bundleName": "com.huawei.hiworld.himusic",
        "vendor": "huawei",
        "version": {
            "code": 2, 
            "name": "2.0"
        }
        "apiVersion": {
            "compatible": 3, 
            "target": 3
        }
    },
    "deviceConfig": {
        "default": {
        }
    },
    "module": {
        "package": "com.huawei.hiworld.himusic.entry",
        "name": ".MainApplication",
        "supportedModes": [
            "drive"
        ],
        "distro": {
            "moduleType": "entry",
            "deliveryWithInstall": true,
            "moduleName": "hap-car"
        },
        "deviceType": [
            "car"
        ],

 
        "abilities": [
            {
                "name": ".MainAbility",
                "description": "himusic main ability",
                "icon": "$media:ic_launcher",
                "label": "HiMusic",
                "launchType": "standard",
                "orientation": "unspecified",
                "visible": true,
                "skills": [
                    {
                        "actions": [
                            "action.system.home"
                        ],
                        "entities": [
                            "entity.system.home"
                        ]
                    }
                ],
                "type": "page",
                "formEnabled": false
            },
            {
                "name": ".PlayService",
                "description": "himusic play ability",
                "icon": "$media:ic_launcher",
                "label": "HiMusic",
                "launchType": "standard",
                "orientation": "unspecified",
                "visible": false,
                "skills": [
                    {
                        "actions": [
                            "action.play.music",
                            "action.stop.music"
                        ],
                        "entities": [
                            "entity.audio"
                        ]
                    }
                ],
                "type": "service",
                "formEnabled": false,
                "backgroundModes": [
                    "audioPlayback"
                ]
            },
            {
                "name": ".UserADataAbility",
                "type": "data",
                "uri": "dataability://com.huawei.hiworld.himusic.UserADataAbility",
                "visible": true
            }
        ],
        "reqPermissions": [{
                "name": "ohos.permission.DISTRIBUTED_DATASYNC",
                "reason": "",
                "usedScene": {
                    "ability": [
                        "com.huawei.hiworld.himusic.entry.MainAbility",
                        "com.huawei.hiworld.himusic.entry.PlayService"
                    ],
                    "when": "inuse"
                }
            }
        ]
    }
}
鸿蒙OS 配置文件的元素
鸿蒙OS 资源文件分类
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

鸿蒙OS 开发

鸿蒙OS 术语

鸿蒙OS Java API参考

鸿蒙OS ohos.aafwk.ability

鸿蒙OS ohos.aafwk.abilityjet.activedata

鸿蒙OS ohos.aafwk.content

鸿蒙OS java.lang

鸿蒙OS java.Util

鸿蒙OS java.Util class

鸿蒙OS ohos.data.dataability

鸿蒙OS ohos.data.dataability class

鸿蒙OS ohos.agp.components

鸿蒙OS ohos.agp.components interface

鸿蒙OS ohos.agp.components class

鸿蒙OS ohos.global.configuration

鸿蒙OS java.io

鸿蒙OS ohos.data.resultset

鸿蒙OS ohos.data.resultset interface

关闭

MIP.setData({ 'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false}, 'pageFontSize' : getCookie('pageFontSize') || 20 }); MIP.watch('pageTheme', function(newValue){ setCookie('pageTheme', JSON.stringify(newValue)) }); MIP.watch('pageFontSize', function(newValue){ setCookie('pageFontSize', newValue) }); function setCookie(name, value){ var days = 1; var exp = new Date(); exp.setTime(exp.getTime() + days*24*60*60*1000); document.cookie = name + '=' + value + ';expires=' + exp.toUTCString(); } function getCookie(name){ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null; }