js-apis-Context.md 41.1 KB
Newer Older
W
wusongqing 已提交
1
# Context
W
wusongqing 已提交
2

3 4
The **Context** module provides context for abilities or applications. It allows access to application-specific resources, as well as permission requests and verification.

W
wusongqing 已提交
5
> **NOTE**
6 7 8
>
> The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version. 
>
W
wusongqing 已提交
9
> The APIs of this module can be used only in the FA model.
W
wusongqing 已提交
10

W
wusongqing 已提交
11 12
## Usage

13
The **Context** object is created in a **featureAbility** and returned through its **getContext()** API. Therefore, you must import the **@ohos.ability.featureAbility** package before using the **Context** module. An example is as follows:
W
wusongqing 已提交
14 15 16 17 18 19 20

```js
import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext();
context.getOrCreateLocalDir()
```

W
wusongqing 已提交
21
## Context.getOrCreateLocalDir<sup>7+</sup>
W
wusongqing 已提交
22

W
wusongqing 已提交
23
getOrCreateLocalDir(callback: AsyncCallback\<string>): void
W
wusongqing 已提交
24

W
wusongqing 已提交
25
Obtains the local root directory of the application. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
26

W
wusongqing 已提交
27
If this API is called for the first time, a root directory will be created.
W
wusongqing 已提交
28

W
wusongqing 已提交
29
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
W
wusongqing 已提交
30

W
wusongqing 已提交
31
**Parameters**
W
wusongqing 已提交
32

W
wusongqing 已提交
33
| Name    | Type                  | Mandatory| Description                      |
W
wusongqing 已提交
34
| -------- | ---------------------- | ---- | -------------------------- |
W
wusongqing 已提交
35
| callback | AsyncCallback\<string> | Yes  | Callback used to return the local root directory.|
W
wusongqing 已提交
36

W
wusongqing 已提交
37
**Example**
W
wusongqing 已提交
38 39 40 41 42 43 44 45 46 47 48

```js
import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext();
context.getOrCreateLocalDir((err, data)=>{
    console.info("data=" + data);
})
```



W
wusongqing 已提交
49
## Context.getOrCreateLocalDir<sup>7+</sup>
W
wusongqing 已提交
50

W
wusongqing 已提交
51
getOrCreateLocalDir(): Promise\<string>
W
wusongqing 已提交
52

W
wusongqing 已提交
53
Obtains the local root directory of the application. This API uses a promise to return the result.
W
wusongqing 已提交
54

W
wusongqing 已提交
55
If this API is called for the first time, a root directory will be created.
W
wusongqing 已提交
56

W
wusongqing 已提交
57
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
W
wusongqing 已提交
58

W
wusongqing 已提交
59
**Return value**
W
wusongqing 已提交
60

W
wusongqing 已提交
61
| Type            | Description                  |
W
wusongqing 已提交
62
| ---------------- | ---------------------- |
W
wusongqing 已提交
63
| Promise\<string> | Promise used to return the local root directory.|
W
wusongqing 已提交
64

W
wusongqing 已提交
65
**Example**
W
wusongqing 已提交
66 67 68 69

```js
import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext();
W
wusongqing 已提交
70 71
context.getOrCreateLocalDir().then((data) => {
    console.info("data=" + data);
W
wusongqing 已提交
72 73 74 75 76
});
```



W
wusongqing 已提交
77
## Context.verifyPermission<sup>7+</sup>
W
wusongqing 已提交
78

W
wusongqing 已提交
79
verifyPermission(permission: string, options: PermissionOptions, callback: AsyncCallback\<number>): void
W
wusongqing 已提交
80

W
wusongqing 已提交
81
Verifies whether a specific PID and UID have the given permission. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
82

W
wusongqing 已提交
83
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
W
wusongqing 已提交
84

W
wusongqing 已提交
85
**Parameters**
W
wusongqing 已提交
86

W
wusongqing 已提交
87
| Name      | Type                                   | Mandatory| Description                                 |
W
wusongqing 已提交
88
| ---------- | --------------------------------------- | ---- | ------------------------------------- |
W
wusongqing 已提交
89 90
| permission | string                                  | Yes  | Name of the permission to verify.                     |
| options    | [PermissionOptions](#permissionoptions) | Yes  | Permission options.                           |
91
| callback   | AsyncCallback\<number>                  | Yes  | Callback used to return the permission verification result. The value **0** means that the PID and UID have the given permission, and the value **-1** means the opposite.|
W
wusongqing 已提交
92

W
wusongqing 已提交
93
**Example**
W
wusongqing 已提交
94 95 96 97 98

```js
import featureAbility from '@ohos.ability.featureAbility'
import bundle from '@ohos.bundle'
var context = featureAbility.getContext();
W
wusongqing 已提交
99 100
bundle.getBundleInfo('com.context.test', 1, (err,datainfo) =>{
	context.verifyPermission("com.example.permission", {uid:datainfo.uid});
W
wusongqing 已提交
101
});
W
wusongqing 已提交
102 103 104 105
```



W
wusongqing 已提交
106
## Context.verifyPermission<sup>7+</sup>
W
wusongqing 已提交
107

W
wusongqing 已提交
108
verifyPermission(permission: string, callback: AsyncCallback\<number>): void
W
wusongqing 已提交
109

W
wusongqing 已提交
110
Verifies whether the current PID and UID have the given permission. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
111

W
wusongqing 已提交
112
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
W
wusongqing 已提交
113

W
wusongqing 已提交
114
**Parameters**
W
wusongqing 已提交
115

W
wusongqing 已提交
116
| Name      | Type                  | Mandatory| Description                                 |
W
wusongqing 已提交
117
| ---------- | ---------------------- | ---- | ------------------------------------- |
W
wusongqing 已提交
118
| permission | string                 | Yes  | Name of the permission to verify.                     |
119
| callback   | AsyncCallback\<number> | Yes  | Callback used to return the permission verification result. The value **0** means that the PID and UID have the given permission, and the value **-1** means the opposite.|
W
wusongqing 已提交
120

W
wusongqing 已提交
121
**Example**
W
wusongqing 已提交
122 123 124 125 126 127 128

```js
import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext();
context.verifyPermission("com.example.permission")
```

W
wusongqing 已提交
129
## Context.verifyPermission<sup>7+</sup>
W
wusongqing 已提交
130

W
wusongqing 已提交
131
verifyPermission(permission: string, options?: PermissionOptions): Promise\<number>
W
wusongqing 已提交
132

W
wusongqing 已提交
133
Verifies whether a specific PID and UID have the given permission. This API uses a promise to return the result.
W
wusongqing 已提交
134

W
wusongqing 已提交
135
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
W
wusongqing 已提交
136

W
wusongqing 已提交
137
**Parameters**
W
wusongqing 已提交
138

W
wusongqing 已提交
139
| Name      | Type                                   | Mandatory| Description            |
W
wusongqing 已提交
140
| ---------- | --------------------------------------- | ---- | ---------------- |
W
wusongqing 已提交
141 142
| permission | string                                  | Yes  | Name of the permission to verify.|
| options    | [PermissionOptions](#permissionoptions) | No  | Permission options.      |
W
wusongqing 已提交
143

W
wusongqing 已提交
144
**Return value**
W
wusongqing 已提交
145

W
wusongqing 已提交
146
| Type            | Description                                                       |
W
wusongqing 已提交
147
| ---------------- | ----------------------------------------------------------- |
148
| Promise\<number> | Promise used to return the permission verification result. The value **0** means that the PID and UID have the given permission, and the value **-1** means the opposite.|
W
wusongqing 已提交
149

W
wusongqing 已提交
150
**Example**
W
wusongqing 已提交
151 152 153 154

```js
import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext();
W
wusongqing 已提交
155
var Permission = {pid:1};
W
wusongqing 已提交
156 157 158
context.verifyPermission('com.context.permission',Permission).then((data) => {
    console.info("======================>verifyPermissionCallback====================>");
    console.info("====>data====>" + JSON.stringify(data));
W
wusongqing 已提交
159 160 161 162 163
});
```



W
wusongqing 已提交
164
## Context.requestPermissionsFromUser<sup>7+</sup>
W
wusongqing 已提交
165

W
wusongqing 已提交
166
requestPermissionsFromUser(permissions: Array\<string>, requestCode: number, resultCallback: AsyncCallback<[PermissionRequestResult](#permissionrequestresult)>): void
W
wusongqing 已提交
167

W
wusongqing 已提交
168
Requests certain permissions from the system. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
169

W
wusongqing 已提交
170
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
W
wusongqing 已提交
171

W
wusongqing 已提交
172
**Parameters**
W
wusongqing 已提交
173

W
wusongqing 已提交
174
| Name          | Type                                                        | Mandatory| Description                                           |
W
wusongqing 已提交
175
| -------------- | ------------------------------------------------------------ | ---- | ----------------------------------------------- |
W
wusongqing 已提交
176 177 178
| permissions    | Array\<string>                                               | Yes  | Permissions to request. This parameter cannot be **null**.       |
| requestCode    | number                                                       | Yes  | Request code to be passed to **PermissionRequestResult**.|
| resultCallback | AsyncCallback<[PermissionRequestResult](#permissionrequestresult)> | Yes  | Permission request result.                             |
W
wusongqing 已提交
179

W
wusongqing 已提交
180
**Example**
W
wusongqing 已提交
181 182 183 184

```js
import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext();
W
wusongqing 已提交
185
context.requestPermissionsFromUser(
W
wusongqing 已提交
186 187 188 189 190
    ["com.example.permission1",
     "com.example.permission2",
     "com.example.permission3",
     "com.example.permission4",
     "com.example.permission5"],
W
wusongqing 已提交
191 192 193 194
    1,(err, data)=>{
        console.info("====>requestdata====>" + JSON.stringify(data));
        console.info("====>requesterrcode====>" + JSON.stringify(err.code));
    }
W
wusongqing 已提交
195 196 197 198 199
)
```



W
wusongqing 已提交
200
## Context.getApplicationInfo<sup>7+</sup>
W
wusongqing 已提交
201

W
wusongqing 已提交
202
getApplicationInfo(callback: AsyncCallback\<ApplicationInfo>): void
W
wusongqing 已提交
203

W
wusongqing 已提交
204
Obtains information about the current application. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
205

W
wusongqing 已提交
206
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
W
wusongqing 已提交
207

W
wusongqing 已提交
208
**Parameters**
W
wusongqing 已提交
209

W
wusongqing 已提交
210
| Name    | Type                           | Mandatory| Description                    |
W
wusongqing 已提交
211
| -------- | ------------------------------- | ---- | ------------------------ |
W
wusongqing 已提交
212
| callback | AsyncCallback\<ApplicationInfo> | Yes  | Callback used to return the application information.|
W
wusongqing 已提交
213

W
wusongqing 已提交
214
**Example**
W
wusongqing 已提交
215 216 217 218 219 220 221 222 223

```js
import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext();
context.getApplicationInfo()
```



W
wusongqing 已提交
224
## Context.getApplicationInfo<sup>7+</sup>
W
wusongqing 已提交
225

W
wusongqing 已提交
226
getApplicationInfo(): Promise\<ApplicationInfo>
W
wusongqing 已提交
227

W
wusongqing 已提交
228
Obtains information about the current application. This API uses a promise to return the result.
W
wusongqing 已提交
229

W
wusongqing 已提交
230
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
W
wusongqing 已提交
231

W
wusongqing 已提交
232
**Return value**
W
wusongqing 已提交
233

W
wusongqing 已提交
234
| Type                     | Description              |
W
wusongqing 已提交
235
| ------------------------- | ------------------ |
W
wusongqing 已提交
236
| Promise\<ApplicationInfo> | Promise used to return the application information.|
W
wusongqing 已提交
237

W
wusongqing 已提交
238
**Example**
W
wusongqing 已提交
239 240 241 242

```js
import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext();
W
wusongqing 已提交
243 244 245
context.getApplicationInfo().then((data) => {
    console.info("=====================>getApplicationInfoCallback===================>");
    console.info("====>data====>" + JSON.stringify(data));
W
wusongqing 已提交
246 247 248 249 250
});
```



W
wusongqing 已提交
251
## Context.getBundleName<sup>7+</sup>
W
wusongqing 已提交
252

W
wusongqing 已提交
253
getBundleName(callback: AsyncCallback\<string>): void
W
wusongqing 已提交
254

255
Obtains the bundle name of this ability. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
256

W
wusongqing 已提交
257
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
W
wusongqing 已提交
258

W
wusongqing 已提交
259
**Parameters**
W
wusongqing 已提交
260

W
wusongqing 已提交
261
| Name    | Type                  | Mandatory| Description                         |
W
wusongqing 已提交
262
| -------- | ---------------------- | ---- | ----------------------------- |
W
wusongqing 已提交
263
| callback | AsyncCallback\<string> | Yes  | Callback used to return the bundle name.|
W
wusongqing 已提交
264

W
wusongqing 已提交
265
**Example**
W
wusongqing 已提交
266 267 268 269 270 271 272 273 274

```js
import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext();
context.getBundleName()
```



W
wusongqing 已提交
275
## Context.getBundleName<sup>7+</sup>
W
wusongqing 已提交
276

W
wusongqing 已提交
277
getBundleName(): Promise\<string>
W
wusongqing 已提交
278

279
Obtains the bundle name of this ability. This API uses a promise to return the result.
W
wusongqing 已提交
280

W
wusongqing 已提交
281
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
W
wusongqing 已提交
282

W
wusongqing 已提交
283
**Return value**
W
wusongqing 已提交
284

W
wusongqing 已提交
285
| Type            | Description                     |
W
wusongqing 已提交
286
| ---------------- | ------------------------- |
W
wusongqing 已提交
287
| Promise\<string> | Promise used to return the bundle name.|
W
wusongqing 已提交
288

W
wusongqing 已提交
289
**Example**
W
wusongqing 已提交
290 291 292 293

```js
import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext();
W
wusongqing 已提交
294 295 296
context.getBundleName().then((data) => {
    console.info("=======================>getBundleNameCallback====================>");
    console.info("====>data====>" + JSON.stringify(data));
W
wusongqing 已提交
297 298 299
});
```

300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518
## Context.getDisplayOrientation<sup>7+</sup>

getDisplayOrientation(callback: AsyncCallback\<bundle.DisplayOrientation>): void

Obtains the display orientation of this ability. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.Ability.AbilityRuntime.Core

**Parameters**

| Name    | Type                  | Mandatory| Description                         |
| -------- | ---------------------- | ---- | ----------------------------- |
| callback | AsyncCallback\<[bundle.DisplayOrientation](js-apis-bundle.md#displayorientation)> | Yes  | Callback used to return the display orientation.|

**Example**

```js
import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext();
context.getDisplayOrientation()
```

## Context.getDisplayOrientation<sup>7+</sup>

getDisplayOrientation(): Promise\<bundle.DisplayOrientation>;

Obtains the display orientation of this ability. This API uses a promise to return the result.

**System capability**: SystemCapability.Ability.AbilityRuntime.Core

**Return value**

| Type            | Description                     |
| ---------------- | ------------------------- |
| Promise\<[bundle.DisplayOrientation](js-apis-bundle.md#displayorientation)> | Promise used to return the display orientation.|

**Example**

```js
import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext();
context.getDisplayOrientation().then((data) => {
    console.info("=======================>getDisplayOrientationCallback====================>");
    console.info("====>data====>" + JSON.stringify(data));
});
```

## Context.setDisplayOrientation<sup>7+</sup>

setDisplayOrientation(orientation: bundle.DisplayOrientation, callback: AsyncCallback\<void>): void

Obtains the display orientation for this ability. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.Ability.AbilityRuntime.Core

**Parameters**

| Name    | Type                  | Mandatory| Description                         |
| -------- | ---------------------- | ---- | ----------------------------- |
| orientation |  [bundle.DisplayOrientation](js-apis-bundle.md#displayorientation) | Yes  | Display orientation to set.|
| callback | AsyncCallback\<[bundle.DisplayOrientation](js-apis-bundle.md#displayorientation)> | Yes  | Callback used to return the display orientation.|

**Example**

```js
import featureAbility from '@ohos.ability.featureAbility'
import bundle from '@ohos.bundle'
var context = featureAbility.getContext();
var orientation=bundle.DisplayOrientation.UNSPECIFIED
context.setDisplayOrientation(orientation, (err) => {
    console.log('---------- setDisplayOrientation fail, err: -----------', err);
});
```

## Context.setDisplayOrientation<sup>7+</sup>

setDisplayOrientation(orientation: bundle.DisplayOrientation): Promise\<void>;

Obtains the display orientation for this ability. This API uses a promise to return the result.

**System capability**: SystemCapability.Ability.AbilityRuntime.Core

**Return value**

| Type            | Description                     |
| ---------------- | ------------------------- |
| orientation |  [bundle.DisplayOrientation](js-apis-bundle.md#displayorientation) | Yes  | Display orientation to set.|
| Promise\<[bundle.DisplayOrientation](js-apis-bundle.md#displayorientation)> | Promise used to return the display orientation.|

**Example**

```js
import featureAbility from '@ohos.ability.featureAbility'
import bundle from '@ohos.bundle'
var context = featureAbility.getContext();
var orientation=bundle.DisplayOrientation.UNSPECIFIED
context.setDisplayOrientation(orientation).then((data) => {
    console.info("=======================>setDisplayOrientationCallback====================>");
    console.info("====>data====>" + JSON.stringify(data));
});
```

## Context.setShowOnLockScreen<sup>7+</sup>

setShowOnLockScreen(show: boolean, callback: AsyncCallback\<void>): void

Sets whether to show this feature at the top of the lock screen each time the lock screen is displayed so that the feature remains activated. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.Ability.AbilityRuntime.Core

**Parameters**

| Name    | Type                  | Mandatory| Description                         |
| -------- | ---------------------- | ---- | ----------------------------- |
| show |  boolean | Yes  | Whether to show this feature at the top of the lock screen. The value **true** means to show this feature at the top of the lock screen, and **false** means the opposite.|
| callback | AsyncCallback\<void> | Yes  | Callback used to return the result.|

**Example**

```js
import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext();
var show=true
context.setShowOnLockScreen(show, (err) => {
       console.log('---------- setShowOnLockScreen fail, err: -----------', err);
});
```

## Context.setShowOnLockScreen<sup>7+</sup>

setShowOnLockScreen(show: boolean): Promise\<void>;

Sets whether to show this feature at the top of the lock screen each time the lock screen is displayed so that the feature remains activated. This API uses a promise to return the result.

**System capability**: SystemCapability.Ability.AbilityRuntime.Core

**Parameters**

| Name    | Type                  | Mandatory| Description                         |
| -------- | ---------------------- | ---- | ----------------------------- |
| show |  boolean | Yes  | Whether to show this feature at the top of the lock screen. The value **true** means to show this feature at the top of the lock screen, and **false** means the opposite.|

**Return value**

| Type            | Description                     |
| ---------------- | ------------------------- |
|  Promise\<void>| Promise used to return the result.|

**Example**

```js
import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext();
var show=true
context.setShowOnLockScreen(show).then((data) => {
    console.info("=======================>setShowOnLockScreenCallback====================>");
    console.info("====>data====>" + JSON.stringify(data));
});
```

## Context.setWakeUpScreen<sup>7+</sup>

setWakeUpScreen(wakeUp: boolean, callback: AsyncCallback\<void>): void

Sets whether to wake up the screen when this feature is restored. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.Ability.AbilityRuntime.Core

**Parameters**

| Name    | Type                  | Mandatory| Description                         |
| -------- | ---------------------- | ---- | ----------------------------- |
| wakeUp |  boolean | Yes  | Whether to wake up the screen. The value **true** means to wake up the screen, and **false** means the opposite.|
| callback | AsyncCallback\<void> | Yes  | Callback used to return the result.|

**Example**

```js
import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext();
var wakeUp=true
context.setWakeUpScreen(wakeUp, (err) => {
       console.log('---------- setWakeUpScreen fail, err: -----------', err);
});
```

## Context.setWakeUpScreen<sup>7+</sup>

setWakeUpScreen(wakeUp: boolean): Promise\<void>; 

Sets whether to wake up the screen when this feature is restored. This API uses a promise to return the result.

**System capability**: SystemCapability.Ability.AbilityRuntime.Core

**Parameters**

| Name    | Type                  | Mandatory| Description                         |
| -------- | ---------------------- | ---- | ----------------------------- |
| wakeUp |  boolean | Yes  | Whether to wake up the screen. The value **true** means to wake up the screen, and **false** means the opposite.|

**Return value**

| Type            | Description                     |
| ---------------- | ------------------------- |
|  Promise\<void>| Promise used to return the result.|

**Example**

```js
import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext();
var wakeUp=true
context.setWakeUpScreen(wakeUp).then((data) => {
    console.info("=======================>setWakeUpScreenCallback====================>");
    console.info("====>data====>" + JSON.stringify(data));
});
```


W
wusongqing 已提交
519 520


W
wusongqing 已提交
521
## Context.getProcessInfo<sup>7+</sup>
W
wusongqing 已提交
522

W
wusongqing 已提交
523
getProcessInfo(callback: AsyncCallback\<ProcessInfo>): void
W
wusongqing 已提交
524

W
wusongqing 已提交
525
Obtains information about the current process, including the PID and process name. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
526

W
wusongqing 已提交
527
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
W
wusongqing 已提交
528

W
wusongqing 已提交
529
**Parameters**
W
wusongqing 已提交
530

W
wusongqing 已提交
531
| Name    | Type                       | Mandatory| Description                |
W
wusongqing 已提交
532
| -------- | --------------------------- | ---- | -------------------- |
W
wusongqing 已提交
533
| callback | AsyncCallback\<ProcessInfo> | Yes  | Callback used to return the process information.|
W
wusongqing 已提交
534

W
wusongqing 已提交
535
**Example**
W
wusongqing 已提交
536 537 538 539 540 541 542 543 544

```js
import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext();
context.getProcessInfo()
```



W
wusongqing 已提交
545
## Context.getProcessInfo<sup>7+</sup>
W
wusongqing 已提交
546

W
wusongqing 已提交
547
getProcessInfo(): Promise\<ProcessInfo>
W
wusongqing 已提交
548

W
wusongqing 已提交
549
Obtains information about the current process, including the PID and process name. This API uses a promise to return the result.
W
wusongqing 已提交
550

W
wusongqing 已提交
551
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
W
wusongqing 已提交
552

W
wusongqing 已提交
553
**Return value**
W
wusongqing 已提交
554

W
wusongqing 已提交
555
| Type                 | Description          |
W
wusongqing 已提交
556
| --------------------- | -------------- |
W
wusongqing 已提交
557
| Promise\<ProcessInfo> | Promise used to return the process information.|
W
wusongqing 已提交
558

W
wusongqing 已提交
559
**Example**
W
wusongqing 已提交
560 561 562 563

```js
import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext();
W
wusongqing 已提交
564 565 566
context.getProcessInfo().then((data) => {
    console.info("=======================>getProcessInfoCallback====================>");
    console.info("====>data====>" + JSON.stringify(data));
W
wusongqing 已提交
567 568 569 570 571
});
```



W
wusongqing 已提交
572
## Context.getElementName<sup>7+</sup>
W
wusongqing 已提交
573

W
wusongqing 已提交
574
getElementName(callback: AsyncCallback\<ElementName>): void
W
wusongqing 已提交
575

576
Obtains the **ohos.bundle.ElementName** object of this ability. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
577

W
wusongqing 已提交
578
This API is available only to Page abilities.
W
wusongqing 已提交
579

W
wusongqing 已提交
580
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
W
wusongqing 已提交
581

W
wusongqing 已提交
582
**Parameters**
W
wusongqing 已提交
583

W
wusongqing 已提交
584
| Name    | Type                       | Mandatory| Description                                          |
W
wusongqing 已提交
585
| -------- | --------------------------- | ---- | ---------------------------------------------- |
W
wusongqing 已提交
586
| callback | AsyncCallback\<ElementName> | Yes  | Callback used to return the **ohos.bundle.ElementName** object.|
W
wusongqing 已提交
587

W
wusongqing 已提交
588
**Example**
W
wusongqing 已提交
589 590 591 592 593 594 595 596 597

```js
import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext();
context.getElementName()
```



W
wusongqing 已提交
598
## Context.getElementName<sup>7+</sup>
W
wusongqing 已提交
599

W
wusongqing 已提交
600
getElementName(): Promise\<ElementName>
W
wusongqing 已提交
601

602
Obtains the **ohos.bundle.ElementName** object of this ability. This API uses a promise to return the result.
W
wusongqing 已提交
603

W
wusongqing 已提交
604
This API is available only to Page abilities.
W
wusongqing 已提交
605

W
wusongqing 已提交
606
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
W
wusongqing 已提交
607

W
wusongqing 已提交
608
**Return value**
W
wusongqing 已提交
609

W
wusongqing 已提交
610
| Type                 | Description                                      |
W
wusongqing 已提交
611
| --------------------- | ------------------------------------------ |
W
wusongqing 已提交
612
| Promise\<ElementName> | Promise used to return the **ohos.bundle.ElementName** object.|
W
wusongqing 已提交
613

W
wusongqing 已提交
614
**Example**
W
wusongqing 已提交
615 616 617 618

```js
import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext();
W
wusongqing 已提交
619 620 621
context.getElementName().then((data) => {
    console.info("=======================>getElementNameCallback====================>");
    console.info("====>data====>" + JSON.stringify(data));
W
wusongqing 已提交
622 623 624
});
```

W
wusongqing 已提交
625
## Context.getProcessName<sup>7+</sup>
W
wusongqing 已提交
626

W
wusongqing 已提交
627
getProcessName(callback: AsyncCallback\<string>): void
W
wusongqing 已提交
628

W
wusongqing 已提交
629
Obtains the name of the current process. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
630

W
wusongqing 已提交
631
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
W
wusongqing 已提交
632

W
wusongqing 已提交
633
**Parameters**
W
wusongqing 已提交
634

W
wusongqing 已提交
635
| Name    | Type                  | Mandatory| Description                |
W
wusongqing 已提交
636
| -------- | ---------------------- | ---- | -------------------- |
W
wusongqing 已提交
637
| callback | AsyncCallback\<string> | Yes  | Callback used to return the process name.|
W
wusongqing 已提交
638

W
wusongqing 已提交
639
**Example**
W
wusongqing 已提交
640 641 642 643 644 645 646 647 648

```js
import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext();
context.getProcessName()
```



W
wusongqing 已提交
649
## Context.getProcessName<sup>7+</sup>
W
wusongqing 已提交
650

W
wusongqing 已提交
651
getProcessName(): Promise\<string>
W
wusongqing 已提交
652

W
wusongqing 已提交
653
Obtains the name of the current process. This API uses a promise to return the result.
W
wusongqing 已提交
654

W
wusongqing 已提交
655
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
W
wusongqing 已提交
656

W
wusongqing 已提交
657
**Return value**
W
wusongqing 已提交
658

W
wusongqing 已提交
659
| Type            | Description                |
W
wusongqing 已提交
660
| ---------------- | -------------------- |
W
wusongqing 已提交
661
| Promise\<string> | Promise used to return the process name.|
W
wusongqing 已提交
662

W
wusongqing 已提交
663
**Example**
W
wusongqing 已提交
664 665 666 667

```js
import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext();
W
wusongqing 已提交
668 669 670
context.getProcessName().then((data) => {
    console.info("=======================>getProcessNameCallback====================>");
    console.info("====>data====>" + JSON.stringify(data));
W
wusongqing 已提交
671 672 673 674 675
});
```



W
wusongqing 已提交
676
## Context.getCallingBundle<sup>7+</sup>
W
wusongqing 已提交
677

W
wusongqing 已提交
678
getCallingBundle(callback: AsyncCallback\<string>): void
W
wusongqing 已提交
679

W
wusongqing 已提交
680
Obtains the bundle name of the calling ability. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
681

W
wusongqing 已提交
682
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
W
wusongqing 已提交
683

W
wusongqing 已提交
684
**Parameters**
W
wusongqing 已提交
685

W
wusongqing 已提交
686
| Name    | Type                  | Mandatory| Description                     |
W
wusongqing 已提交
687
| -------- | ---------------------- | ---- | ------------------------- |
W
wusongqing 已提交
688
| callback | AsyncCallback\<string> | Yes  | Callback used to return the bundle name.|
W
wusongqing 已提交
689

W
wusongqing 已提交
690
**Example**
W
wusongqing 已提交
691 692 693 694 695 696 697 698 699

```js
import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext();
context.getCallingBundle()
```



W
wusongqing 已提交
700
## Context.getCallingBundle<sup>7+</sup>
W
wusongqing 已提交
701

W
wusongqing 已提交
702
getCallingBundle(): Promise\<string>
W
wusongqing 已提交
703

W
wusongqing 已提交
704
Obtains the bundle name of the calling ability. This API uses a promise to return the result.
W
wusongqing 已提交
705

W
wusongqing 已提交
706
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
W
wusongqing 已提交
707

W
wusongqing 已提交
708
**Return value**
W
wusongqing 已提交
709

W
wusongqing 已提交
710
| Type           | Description                     |
W
wusongqing 已提交
711
| --------------- | ------------------------- |
W
wusongqing 已提交
712
| Promise\<string> | Promise used to return the bundle name.|
W
wusongqing 已提交
713

W
wusongqing 已提交
714
**Example**
W
wusongqing 已提交
715 716 717 718

```js
import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext();
W
wusongqing 已提交
719 720 721
context.getCallingBundle().then((data) => {
    console.info("======================>getCallingBundleCallback====================>");
    console.info("====>data====>" + JSON.stringify(data));
W
wusongqing 已提交
722 723
});
```
W
wusongqing 已提交
724

W
wusongqing 已提交
725 726 727 728
## Context.getCacheDir

getCacheDir(callback: AsyncCallback\<string>): void

729
Obtains the cache directory of the application in the internal storage. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
730 731 732 733 734

**System capability**: SystemCapability.Ability.AbilityRuntime.Core

**Parameters**

W
wusongqing 已提交
735
| Name    | Type                  | Mandatory| Description                     |
W
wusongqing 已提交
736
| -------- | ---------------------- | ---- | ------------------------- |
W
wusongqing 已提交
737
| callback | AsyncCallback\<string> | Yes  | Callback used to return the cache directory.|
W
wusongqing 已提交
738 739 740 741 742

**Example**

```js
import featureAbility from '@ohos.ability.featureAbility'
W
wusongqing 已提交
743
var context = featureAbility.getContext();
W
wusongqing 已提交
744 745 746 747 748 749 750 751 752 753 754 755 756
context.getCacheDir((err, data) => {
    if (err) {
        console.error('Operation failed. Cause: ' + JSON.stringify(err));
        return;
    }
    console.info('Operation successful. Data:' + JSON.stringify(data));
});
```

## Context.getCacheDir

getCacheDir(): Promise\<string>

757
Obtains the cache directory of the application in the internal storage. This API uses a promise to return the result.
W
wusongqing 已提交
758 759 760 761 762

**System capability**: SystemCapability.Ability.AbilityRuntime.Core

**Return value**

W
wusongqing 已提交
763
| Type           | Description                     |
W
wusongqing 已提交
764
| --------------- | ------------------------- |
W
wusongqing 已提交
765
| Promise\<string> | Promise used to return the cache directory.|
W
wusongqing 已提交
766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781

**Example**

```js
import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext();
context.getCacheDir().then((data) => {
    console.info("======================>getCacheDirPromsie====================>");
    console.info("====>data====>" + JSON.stringify(data));
});
```

## Context.getFilesDir

getFilesDir(callback: AsyncCallback\<string>): void

782
Obtains the file directory of the application in the internal storage. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
783 784 785 786 787

**System capability**: SystemCapability.Ability.AbilityRuntime.Core

**Parameters**

W
wusongqing 已提交
788
| Name    | Type                  | Mandatory| Description                     |
W
wusongqing 已提交
789
| -------- | ---------------------- | ---- | ------------------------- |
W
wusongqing 已提交
790
| callback | AsyncCallback\<string> | Yes  | Callback used to return the file directory.|
W
wusongqing 已提交
791 792 793 794 795

**Example**

```js
import featureAbility from '@ohos.ability.featureAbility'
W
wusongqing 已提交
796
var context = featureAbility.getContext();
W
wusongqing 已提交
797 798 799 800 801 802 803 804 805 806 807 808 809
context.getFilesDir((err, data) => {
    if (err) {
        console.error('Operation failed. Cause: ' + JSON.stringify(err));
        return;
    }
    console.info('Operation successful. Data:' + JSON.stringify(data));
});
```

## Context.getFilesDir

getFilesDir(): Promise\<string>

810
Obtains the file directory of the application in the internal storage. This API uses a promise to return the result.
W
wusongqing 已提交
811 812 813 814 815

**System capability**: SystemCapability.Ability.AbilityRuntime.Core

**Return value**

W
wusongqing 已提交
816
| Type           | Description                     |
W
wusongqing 已提交
817
| --------------- | ------------------------- |
W
wusongqing 已提交
818
| Promise\<string> | Promise used to return the file directory.|
W
wusongqing 已提交
819 820 821 822 823 824 825 826 827 828 829 830

**Example**

```js
import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext();
context.getFilesDir().then((data) => {
    console.info("======================>getFilesDirPromsie====================>");
    console.info("====>data====>" + JSON.stringify(data));
});
```

W
wusongqing 已提交
831
## Context.getOrCreateDistributedDir<sup>7+</sup>
W
wusongqing 已提交
832 833 834 835 836 837 838 839 840 841 842

getOrCreateDistributedDir(callback: AsyncCallback\<string>): void

Obtains the distributed file path for storing ability or application data files. This API uses an asynchronous callback to return the result.

If the distributed file path does not exist, the system will create one and return the created path.

**System capability**: SystemCapability.Ability.AbilityRuntime.Core

**Parameters**

W
wusongqing 已提交
843
| Name    | Type                  | Mandatory| Description                     |
W
wusongqing 已提交
844
| -------- | ---------------------- | ---- | ------------------------- |
W
wusongqing 已提交
845
| callback | AsyncCallback\<string> | Yes  | Callback used to return the distributed file path. If the distributed file path does not exist, the system will create one and return the created path.|
W
wusongqing 已提交
846 847 848 849 850 851 852 853 854 855 856 857 858 859 860

**Example**

```js
import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext();
context.getOrCreateDistributedDir((err, data) => {
    if (err) {
        console.error('Operation failed. Cause: ' + JSON.stringify(err));
        return;
    }
    console.info('Operation successful. Data:' + JSON.stringify(data));
});
```

W
wusongqing 已提交
861
## Context.getOrCreateDistributedDir<sup>7+</sup>
W
wusongqing 已提交
862 863 864 865 866 867 868 869 870 871 872

getOrCreateDistributedDir(): Promise\<string>

Obtains the distributed file path for storing ability or application data files. This API uses a promise to return the result.

If the distributed file path does not exist, the system will create one and return the created path.

**System capability**: SystemCapability.Ability.AbilityRuntime.Core

**Return value**

W
wusongqing 已提交
873
| Type           | Description                     |
W
wusongqing 已提交
874
| --------------- | ------------------------- |
W
wusongqing 已提交
875
| Promise\<string> | Promise used to return the distributed file path. If this API is called for the first time, a new path will be created.|
W
wusongqing 已提交
876 877 878 879 880 881 882 883 884 885 886

**Example**

```js
import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext();
context.getOrCreateDistributedDir().then((data) => {
    console.info("====>data====>" + JSON.stringify(data));
});
```

W
wusongqing 已提交
887
## Context.getAppType<sup>7+</sup>
W
wusongqing 已提交
888 889 890 891 892 893 894 895 896

getAppType(callback: AsyncCallback\<string>): void

Obtains the application type. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.Ability.AbilityRuntime.Core

**Parameters**

W
wusongqing 已提交
897
| Name    | Type                  | Mandatory| Description                     |
W
wusongqing 已提交
898
| -------- | ---------------------- | ---- | ------------------------- |
W
wusongqing 已提交
899
| callback | AsyncCallback\<string> | Yes  | Callback used to return the application type.|
W
wusongqing 已提交
900 901 902 903 904 905 906 907 908 909 910 911 912 913 914

**Example**

```js
import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext();
context.getAppType((err, data) => {
    if (err) {
        console.error('Operation failed. Cause: ' + JSON.stringify(err));
        return;
    }
    console.info('Operation successful. Data:' + JSON.stringify(data));
});
```

W
wusongqing 已提交
915
## Context.getAppType<sup>7+</sup>
W
wusongqing 已提交
916 917 918 919 920 921 922 923 924

getAppType(): Promise\<string>

Obtains the application type. This API uses a promise to return the result.

**System capability**: SystemCapability.Ability.AbilityRuntime.Core

**Return value**

W
wusongqing 已提交
925
| Type           | Description                     |
W
wusongqing 已提交
926
| --------------- | ------------------------- |
W
wusongqing 已提交
927
| Promise\<string> | Promise used to return the application type.|
W
wusongqing 已提交
928 929 930 931 932 933 934 935 936 937 938

**Example**

```js
import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext();
context.getAppType().then((data) => {
    console.info("====>data====>" + JSON.stringify(data));
});
```

W
wusongqing 已提交
939
## Context.getHapModuleInfo<sup>7+</sup>
W
wusongqing 已提交
940 941 942 943 944 945 946 947 948

getHapModuleInfo(callback: AsyncCallback\<HapModuleInfo>): void

Obtains the **ModuleInfo** object of the application. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.Ability.AbilityRuntime.Core

**Parameters**

W
wusongqing 已提交
949
| Name    | Type                  | Mandatory| Description                     |
W
wusongqing 已提交
950
| -------- | ---------------------- | ---- | ------------------------- |
951
| callback | AsyncCallback\<[HapModuleInfo](js-apis-bundle-HapModuleInfo.md)> | Yes  | Callback used to return the **ModuleInfo** object.|
W
wusongqing 已提交
952 953 954 955 956 957 958 959 960 961 962 963 964 965 966

**Example**

```js
import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext();
context.getHapModuleInfo((err, data) => {
    if (err) {
        console.error('Operation failed. Cause: ' + JSON.stringify(err));
        return;
    }
    console.info('Operation successful. Data:' + JSON.stringify(data));
});
```

W
wusongqing 已提交
967
## Context.getHapModuleInfo<sup>7+</sup>
W
wusongqing 已提交
968 969 970 971 972 973 974 975 976

getHapModuleInfo(): Promise\<HapModuleInfo>

Obtains the **ModuleInfo** object of the application. This API uses a promise to return the result.

**System capability**: SystemCapability.Ability.AbilityRuntime.Core

**Return value**

W
wusongqing 已提交
977
| Type           | Description                     |
W
wusongqing 已提交
978
| --------------- | ------------------------- |
979
| Promise\<[HapModuleInfo](js-apis-bundle-HapModuleInfo.md)> | Promise used to return the **ModuleInfo** object.|
W
wusongqing 已提交
980 981 982 983 984 985 986 987 988 989 990

**Example**

```js
import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext();
context.getHapModuleInfo().then((data) => {
    console.info("====>data====>" + JSON.stringify(data));
});
```

W
wusongqing 已提交
991
## Context.getAppVersionInfo<sup>7+</sup>
W
wusongqing 已提交
992

993
getAppVersionInfo(callback: AsyncCallback\<AppVersionInfo>): void
W
wusongqing 已提交
994

995
Obtains the version information of this application. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
996 997 998 999 1000

**System capability**: SystemCapability.Ability.AbilityRuntime.Core

**Parameters**

W
wusongqing 已提交
1001
| Name    | Type                  | Mandatory| Description                     |
W
wusongqing 已提交
1002
| -------- | ---------------------- | ---- | ------------------------- |
W
wusongqing 已提交
1003
| callback | AsyncCallback\<[AppVersionInfo](#appversioninfo)> | Yes  | Callback used to return the version information.|
W
wusongqing 已提交
1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018

**Example**

```js
import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext();
context.getAppVersionInfo((err, data) => {
    if (err) {
        console.error('Operation failed. Cause: ' + JSON.stringify(err));
        return;
    }
    console.info('Operation successful. Data:' + JSON.stringify(data));
});
```

W
wusongqing 已提交
1019
## Context.getAppVersionInfo<sup>7+</sup>
W
wusongqing 已提交
1020 1021 1022

getAppVersionInfo(): Promise\<AppVersionInfo>

1023
Obtains the version information of this application. This API uses a promise to return the result.
W
wusongqing 已提交
1024 1025 1026 1027 1028

**System capability**: SystemCapability.Ability.AbilityRuntime.Core

**Return value**

W
wusongqing 已提交
1029
| Type           | Description                     |
W
wusongqing 已提交
1030
| --------------- | ------------------------- |
W
wusongqing 已提交
1031
| Promise\<[AppVersionInfo](#appversioninfo)> | Promise used to return the version information.|
W
wusongqing 已提交
1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042

**Example**

```js
import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext();
context.getAppVersionInfo().then((data) => {
    console.info("====>data====>" + JSON.stringify(data));
});
```

W
wusongqing 已提交
1043
## Context.getAbilityInfo<sup>7+</sup>
W
wusongqing 已提交
1044 1045 1046

getAbilityInfo(callback: AsyncCallback\<AbilityInfo>): void

1047
Obtains information about this ability. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
1048 1049 1050 1051 1052

**System capability**: SystemCapability.Ability.AbilityRuntime.Core

**Parameters**

W
wusongqing 已提交
1053
| Name    | Type                  | Mandatory| Description                     |
W
wusongqing 已提交
1054
| -------- | ---------------------- | ---- | ------------------------- |
1055
| callback | AsyncCallback\<[AbilityInfo](js-apis-bundle-AbilityInfo.md)> | Yes  | Callback used to return the ability information.|
W
wusongqing 已提交
1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070

**Example**

```js
import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext();
context.getAbilityInfo((err, data) => {
    if (err) {
        console.error('Operation failed. Cause: ' + JSON.stringify(err));
        return;
    }
    console.info('Operation successful. Data:' + JSON.stringify(data));
});
```

W
wusongqing 已提交
1071
## Context.getAbilityInfo<sup>7+</sup>
W
wusongqing 已提交
1072 1073 1074

getAbilityInfo(): Promise\<AbilityInfo>

1075
Obtains information about this ability. This API uses a promise to return the result.
W
wusongqing 已提交
1076 1077 1078 1079 1080

**System capability**: SystemCapability.Ability.AbilityRuntime.Core

**Return value**

W
wusongqing 已提交
1081
| Type           | Description                     |
W
wusongqing 已提交
1082
| --------------- | ------------------------- |
1083
| Promise\<[AbilityInfo](js-apis-bundle-AbilityInfo.md)> | Promise used to return the ability information.|
W
wusongqing 已提交
1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094

**Example**

```js
import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext();
context.getAbilityInfo().then((data) => {
    console.info("====>data====>" + JSON.stringify(data));
});
```

W
wusongqing 已提交
1095
## Context.getApplicationContext<sup>7+</sup>
W
wusongqing 已提交
1096 1097 1098 1099 1100 1101 1102 1103 1104

getApplicationContext(): Context

Obtains the context of the application.

**System capability**: SystemCapability.Ability.AbilityRuntime.Core

**Return value**

W
wusongqing 已提交
1105
| Type     | Description  |
W
wusongqing 已提交
1106
| --------- |------ |
W
wusongqing 已提交
1107
|  Context | Application context.|
W
wusongqing 已提交
1108 1109 1110 1111 1112 1113 1114 1115

**Example**

```js
import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext().getApplicationContext();
```

1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220
## Context.isUpdatingConfigurations<sup>7+</sup>

isUpdatingConfigurations(callback: AsyncCallback\<boolean>): void;

Checks whether the configuration of this ability is being changed. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.Ability.AbilityRuntime.Core

**Parameters**

| Name    | Type                  | Mandatory| Description                     |
| -------- | ---------------------- | ---- | ------------------------- |
| callback | AsyncCallback\<boolean> | Yes  | Returns **true** if the configuration of the capability is being changed; returns **false** otherwise.|

**Example**

```js
import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext();
context.isUpdatingConfigurations((err, data) => {
    if (err) {
        console.error('Operation failed. Cause: ' + JSON.stringify(err));
        return;
    }
    console.info('Operation successful. Data:' + JSON.stringify(data));
});
```

## Context.isUpdatingConfigurations<sup>7+</sup>

isUpdatingConfigurations(): Promise\<boolean>;

Checks whether the configuration of this ability is being changed. This API uses a promise to return the result.

**System capability**: SystemCapability.Ability.AbilityRuntime.Core

**Return value**

| Type           | Description                     |
| --------------- | ------------------------- |
|Promise\<boolean> | Returns **true** if the configuration of the capability is being changed; returns **false** otherwise.|

**Example**

```js
import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext();
context.isUpdatingConfigurations().then((data) => {
    console.info("====>data====>" + JSON.stringify(data));
});
```

## Context.printDrawnCompleted<sup>7+</sup>

printDrawnCompleted(callback: AsyncCallback\<void>): void;

Notifies the system of the time required to draw this page function. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.Ability.AbilityRuntime.Core

**Parameters**

| Name    | Type                  | Mandatory| Description                     |
| -------- | ---------------------- | ---- | ------------------------- |
| callback | AsyncCallback\<void> | Yes  | Callback used to return the result.|

**Example**

```js
import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext();
context.printDrawnCompleted((err, data) => {
    if (err) {
        console.error('Operation failed. Cause: ' + JSON.stringify(err));
        return;
    }
    console.info('Operation successful. Data:' + JSON.stringify(data));
});
```

## Context.printDrawnCompleted<sup>7+</sup>

printDrawnCompleted(): Promise\<void>;

Notifies the system of the time required to draw this page function. This API uses a promise to return the result.

**System capability**: SystemCapability.Ability.AbilityRuntime.Core

**Return value**

| Type           | Description                     |
| --------------- | ------------------------- |
|Promise\<void> | Promise used to return the result.|

**Example**

```js
import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext();
context.printDrawnCompleted().then((data) => {
    console.info("====>data====>" + JSON.stringify(data));
});
```


W
wusongqing 已提交
1221
## PermissionOptions<sup>7+</sup>
W
wusongqing 已提交
1222

W
wusongqing 已提交
1223 1224
**System capability**: SystemCapability.Ability.AbilityRuntime.Core

W
wusongqing 已提交
1225
| Name| Readable/Writable| Type  | Mandatory| Description  |
W
wusongqing 已提交
1226
| ---- | -------- | ------ | ---- | ------ |
W
wusongqing 已提交
1227 1228
| pid  | Read-only    | number | No  | Process ID.|
| uid  | Read-only    | number | No  | User ID.|
W
wusongqing 已提交
1229

W
wusongqing 已提交
1230
## PermissionRequestResult<sup>7+</sup>
W
wusongqing 已提交
1231

W
wusongqing 已提交
1232 1233
**System capability**: SystemCapability.Ability.AbilityRuntime.Core

W
wusongqing 已提交
1234
| Name       | Readable/Writable| Type          | Mandatory| Description              |
W
wusongqing 已提交
1235
| ----------- | -------- | -------------- | ---- | ------------------ |
W
wusongqing 已提交
1236 1237 1238
| requestCode | Read-only    | number         | Yes  | Request code passed.|
| permissions | Read-only    | Array\<string> | Yes  | Permissions requested.    |
| authResults | Read-only    | Array\<number> | Yes  | Permission request result.   |
W
wusongqing 已提交
1239

W
wusongqing 已提交
1240
## AppVersionInfo<sup>7+</sup>
W
wusongqing 已提交
1241

1242 1243
**System capability**: SystemCapability.Ability.AbilityRuntime.Core

W
wusongqing 已提交
1244 1245 1246 1247 1248
| Name            | Type| Readable   | Writable  | Description|
| ------          | ------ | ------| ------ | ------    |
| appName         | string | Yes   | No    | Module name.     |
| versionCode     | number | Yes   | No    | Module description.  |
| versionName     | string | Yes   | No    | Module description ID.    |