目录

Development Preparations

Before using Car Kit capabilities, you need to configure the build mode, permissions, and capabilities.

Configuring the Build Mode

When packaging an app, click in the upper right corner of DevEco Studio, change the build mode to release, and click Apply in the lower right corner.

Configuring Permissions

Car Kit provides two types of APIs: navigation APIs and mobility connectivity APIs. You need to configure the corresponding permissions for using these APIs.

Configure required permissions in the app configuration file module.json5 in entry/src/main. The sample code is as follows:

{
  "module": {
    "requestPermissions": [
      {
        "name": "ohos.permission.ACCESS_CAR_DISTRIBUTED_ENGINE"
      },
      {
        "name": "ohos.permission.ACCESS_SERVICE_NAVIGATION_INFO"
      }
    ]
  }
}

Configuring Capabilities

Configure the navigation hop or HiCar capability in the abilities array of the app configuration file module.json5 in entry/src/main. The procedure is as follows:

  1. Configure the actions of the navigation information service in skills.

    If your app has other skills, do not directly modify the existing configuration. Instead, supplement the configuration in the skills array.

    "skills": [
      {
        "entities": [
          "entity.system.default"
        ],
        "actions": [
          "action.navigation.infoservice"
        ]
      },
      // Configure other skills.
      {
        // ...
      }
    ]
  2. Configure the navigation hop or HiCar capability in metadata. The sample code is as follows:

    {
      "module": {
        "abilities": [
         {
            "name": "xxxx",
            "srcEntry": "xxxx",
            "description": "xxxx",
            "skills": [
              {
                "entities": [
                  "entity.system.home"
                ],
                "actions": [
                  "action.system.home"
                ]
              },
              {
                "entities": [
                  "entity.system.default"
                ],
                "actions": [
                  "action.navigation.infoservice"
                ]
              }
            ],
            "metadata": [
              {
                "name" : "carHopCapability",
                "value" : "carHopNavi,getOnCarNavi,insideCarNavi,getOffCarNavi"
              },
              {
                "name" : "hiCarCapability",
                "value" :"basicNavi,shortcutOper,multiScreenUI,mapUIOper,updateNaviStatus,searchPOI"
              }
            ]
          }
        ]
      }
    }

The options of name in metadata are carHopCapability and hiCarCapability.