目录

Background Running

Generally, resources occupied by quick apps will be released after the apps are switched to the background. However, users of apps such as those related to music and sports hope that these apps can still run in the background and provide services. To meet this requirement, background running is supported.

There are two ways for switching a quick app to the background:

  1. The manifest.json file declares required background running APIs.
  2. The current page is the first page opened in a quick app.
  3. At least one background running API (declared in manifest.json) is running.

Suggestions

Configuration Method

Declare the required background running APIs in the manifest.json file, including:

{
  "package": "com.huawei.sample",
   ......
  "config": {
    "logLevel": "trace",
    "background": {
      "features":[
        "system.audio",
        "system.record",
        "system.request",
        "system.geolocation"
      ]
     }
   ......
}

Calling APIs

For details, please refer to Running an App in the Background. resident.start and resident.stop are both empty implementations.

API Types

[h2]APIs That Need to Be Applied for

These APIs must be declared in background of the manifest.json file. A quick app will run in the background only if one of the following APIs is called when a user exits the quick app: system.audio, system.record, system.geolocation, and system.request.

[h2]APIs That Can Be Directly Called

All APIs can be directly called when a quick app is running in the background.

Differences from Implementations in the Vendor Alliance

[h2]APIs

resident.start and resident.stop are both empty implementations. If you want to use an API, apply for them in the manifest.json file.

[h2]Notification Bar

[h2]Stop Running an App in the Background

Huawei will not stop an app when the app run in the background for 20s.