js-apis-basic-features-app-context.md 4.4 KB
Newer Older
Z
zengyawen 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
# Application Context<a name="EN-US_TOPIC_0000001173324607"></a>

## Module to Import<a name="s1959b1529f574b74861e62008289bb21"></a>

```
import app from '@system.app';
```

## Required Permissions<a name="section11257113618419"></a>

None

## app.getInfo<a name="s0e8ff40704e442bc87a848afa47bdfbb"></a>

getInfo\(\): <[AppResponse](#t3e93239d9b134b80957bcdd4acb05291)\>

Obtains the declared information in the  **config.json**  file of an application.

-   Return values

    **Table  1**  AppResponse

    <a name="t3e93239d9b134b80957bcdd4acb05291"></a>
    <table><tbody><tr id="recc81d9f995d44aa87ba9d714b756569"><td class="cellrowborder" valign="top" width="19%"><p id="aa3137ce511d140fba6cc93513a7a91e3"><a name="aa3137ce511d140fba6cc93513a7a91e3"></a><a name="aa3137ce511d140fba6cc93513a7a91e3"></a>Name</p>
    </td>
    <td class="cellrowborder" valign="top" width="13%"><p id="a6b166163db284e5ca8dc0190b36ae40a"><a name="a6b166163db284e5ca8dc0190b36ae40a"></a><a name="a6b166163db284e5ca8dc0190b36ae40a"></a>Type</p>
    </td>
    <td class="cellrowborder" valign="top" width="68%"><p id="a4ba8ead9ee7b48298d9a6ed10659f13b"><a name="a4ba8ead9ee7b48298d9a6ed10659f13b"></a><a name="a4ba8ead9ee7b48298d9a6ed10659f13b"></a>Description</p>
    </td>
    </tr>
    <tr id="row2557173813243"><td class="cellrowborder" valign="top" width="19%"><p id="p898462584011"><a name="p898462584011"></a><a name="p898462584011"></a>appID<sup id="sup193948321350"><a name="sup193948321350"></a><a name="sup193948321350"></a>6+</sup></p>
    </td>
    <td class="cellrowborder" valign="top" width="13%"><p id="p698492564013"><a name="p698492564013"></a><a name="p698492564013"></a>string</p>
    </td>
    <td class="cellrowborder" valign="top" width="68%"><p id="p1998432514020"><a name="p1998432514020"></a><a name="p1998432514020"></a>Bundle name of the application. It uniquely identifies the application.</p>
    </td>
    </tr>
    <tr id="r64430cb15b54497f88ea6330b9a7454c"><td class="cellrowborder" valign="top" width="19%"><p id="a7cccea39636b47cd83188d400eed51e3"><a name="a7cccea39636b47cd83188d400eed51e3"></a><a name="a7cccea39636b47cd83188d400eed51e3"></a>appName</p>
    </td>
    <td class="cellrowborder" valign="top" width="13%"><p id="a2f72300143c441ef9a3fb5dc2f8e4aac"><a name="a2f72300143c441ef9a3fb5dc2f8e4aac"></a><a name="a2f72300143c441ef9a3fb5dc2f8e4aac"></a>string</p>
    </td>
    <td class="cellrowborder" valign="top" width="68%"><p id="a1c9b8d1829ef489e9e0fd1863190d228"><a name="a1c9b8d1829ef489e9e0fd1863190d228"></a><a name="a1c9b8d1829ef489e9e0fd1863190d228"></a>Application name</p>
    </td>
    </tr>
    <tr id="r4f8f612a65b24ae9b75ae53893aeb3b9"><td class="cellrowborder" valign="top" width="19%"><p id="ae036f88e139e4379abdaf4969f0720ea"><a name="ae036f88e139e4379abdaf4969f0720ea"></a><a name="ae036f88e139e4379abdaf4969f0720ea"></a>versionName</p>
    </td>
    <td class="cellrowborder" valign="top" width="13%"><p id="a1d379931a20144f0b6d98f5396202cd9"><a name="a1d379931a20144f0b6d98f5396202cd9"></a><a name="a1d379931a20144f0b6d98f5396202cd9"></a>string</p>
    </td>
    <td class="cellrowborder" valign="top" width="68%"><p id="a70c91c442f7c41439a90ceb9041252e8"><a name="a70c91c442f7c41439a90ceb9041252e8"></a><a name="a70c91c442f7c41439a90ceb9041252e8"></a>Application version name</p>
    </td>
    </tr>
    <tr id="r89cf0afd5f444bd1b66ace0c31a25cda"><td class="cellrowborder" valign="top" width="19%"><p id="a3a86c086e40e475b8fb26cf43fe9a8d6"><a name="a3a86c086e40e475b8fb26cf43fe9a8d6"></a><a name="a3a86c086e40e475b8fb26cf43fe9a8d6"></a>versionCode</p>
    </td>
    <td class="cellrowborder" valign="top" width="13%"><p id="abcfd352ff3d84552938de0e2daf0703e"><a name="abcfd352ff3d84552938de0e2daf0703e"></a><a name="abcfd352ff3d84552938de0e2daf0703e"></a>number</p>
    </td>
    <td class="cellrowborder" valign="top" width="68%"><p id="af943e2ec7622407387d25d9331a01245"><a name="af943e2ec7622407387d25d9331a01245"></a><a name="af943e2ec7622407387d25d9331a01245"></a>Application version</p>
    </td>
    </tr>
    </tbody>
    </table>

-   Example

    ```
    export default {    
      getInfo(){        
        var info = app.getInfo();        
          console.log(JSON.stringify(info));    
      } 
    }
    ```


## app.terminate<a name="section974325124119"></a>

terminate\(\): void

Destroys the current ability.

-   Example

    ```
    export default {    
      terminate(){        
        app.terminate();    
      }}
    ```