1# ApplicationContext (System API) 2 3The ApplicationContext module inherits from [Context](js-apis-inner-application-context.md). It provides application-level context capabilities, including APIs for registering and deregistering the lifecycle of application components. 4 5> **NOTE** 6> 7> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. 8> 9> This topic describes only system APIs provided by the module. For details about its public APIs, see [ApplicationContext](js-apis-inner-application-applicationContext.md). 10 11## Modules to Import 12 13```ts 14import { common } from '@kit.AbilityKit'; 15``` 16 17## Instructions 18 19Before calling any APIs in ApplicationContext, obtain an ApplicationContext instance through the context instance. 20 21## ApplicationContext.preloadUIExtensionAbility<sup>12+</sup> 22 23preloadUIExtensionAbility(want: Want): Promise\<void\> 24 25Preloads a UIExtensionAbility instance. 26The preloaded UIExtensionAbility instance is sent to the **onCreate** lifecycle of the UIExtensionAbility and waits to be loaded by the current application. A UIExtensionAbility instance can be preloaded for multiple times. Each time a preloaded UIExtensionAbility instance is loaded, the next preloaded UIExtensionAbility instance is sent to the **onCreate** lifecycle of the UIExtensionAbility. 27 28**System capability**: SystemCapability.Ability.AbilityRuntime.Core 29 30**System API**: This is a system API. 31 32| Name| Type| Mandatory| Description| 33| -------- | -------- | -------- | -------- | 34| want | [Want](js-apis-app-ability-want.md) | Yes| Want information of the UIExtensionAbility.| 35 36**Return value** 37 38| Type| Description| 39| -------- | -------- | 40| Promise<void> | Promise that returns no value.| 41 42**Error codes** 43 44For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Ability Error Codes](errorcode-ability.md). 45 46| ID| Error Message| 47| ------- | -------------------------------- | 48| 201 | The application does not have permission to call the interface. | 49| 202 | The application is not system-app, can not use system-api. | 50| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. | 51| 16000001 | The specified ability does not exist. | 52| 16000002 | Incorrect ability type. | 53| 16000004 | Cannot start an invisible component. | 54| 16200011 | The context does not exist. | 55| 16000050 | Internal error. | 56 57**Example** 58 59```ts 60import { UIAbility, Want } from '@kit.AbilityKit'; 61import { BusinessError } from '@kit.BasicServicesKit'; 62 63export default class EntryAbility extends UIAbility { 64 onCreate() { 65 let want: Want = { 66 bundleName: 'com.ohos.uiextensionprovider', 67 abilityName: 'UIExtensionProvider', 68 moduleName: 'entry', 69 parameters: { 70 // The value must be the same as the value of type in the module.json5 file of the UIExtensionAbility. 71 'ability.want.params.uiExtensionType': 'sys/commonUI' 72 } 73 }; 74 try { 75 let applicationContext = this.context.getApplicationContext(); 76 applicationContext.preloadUIExtensionAbility(want) 77 .then(() => { 78 // Carry out normal service processing. 79 console.info('preloadUIExtensionAbility succeed'); 80 }) 81 .catch((err: BusinessError) => { 82 // Process service logic errors. 83 console.error('preloadUIExtensionAbility failed'); 84 }); 85 } catch (err) { 86 // Process input parameter errors. 87 let code = (err as BusinessError).code; 88 let message = (err as BusinessError).message; 89 console.error(`preloadUIExtensionAbility failed. code: ${code}, msg: ${message}`); 90 } 91 } 92} 93``` 94