1e41f4b71Sopenharmony_ci# AutoFillExtensionContext (System API) 
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ciThe **AutoFillExtensionContext** module, inherited from [ExtensionContext](js-apis-inner-application-extensionContext.md), provides the context environment for the AutoFillExtensionAbility.
4e41f4b71Sopenharmony_ci
5e41f4b71Sopenharmony_ci> **NOTE**
6e41f4b71Sopenharmony_ci>
7e41f4b71Sopenharmony_ci> The initial APIs of this module are supported since API version 11. Newly added APIs will be marked with a superscript to indicate their earliest API version. 
8e41f4b71Sopenharmony_ci> The APIs of this module can be used only in the stage model. 
9e41f4b71Sopenharmony_ci> The APIs provided by this module are system APIs.
10e41f4b71Sopenharmony_ci
11e41f4b71Sopenharmony_ci## Usage
12e41f4b71Sopenharmony_ci
13e41f4b71Sopenharmony_ciBefore using the **AutoFillExtensionContext** module, you must define a child class that inherits from **AutoFillExtensionAbility**.
14e41f4b71Sopenharmony_ci
15e41f4b71Sopenharmony_ci```ts
16e41f4b71Sopenharmony_ciimport { AutoFillExtensionAbility } from '@kit.AbilityKit';
17e41f4b71Sopenharmony_ci
18e41f4b71Sopenharmony_ciclass MyAutoFillExtensionAbility extends AutoFillExtensionAbility {
19e41f4b71Sopenharmony_ci  onCreate() {
20e41f4b71Sopenharmony_ci    let AutoFillExtensionContext = this.context;
21e41f4b71Sopenharmony_ci  }
22e41f4b71Sopenharmony_ci}
23e41f4b71Sopenharmony_ci```
24e41f4b71Sopenharmony_ci
25e41f4b71Sopenharmony_ci## AutoFillExtensionContext.reloadInModal<sup>12+</sup>
26e41f4b71Sopenharmony_ci
27e41f4b71Sopenharmony_cireloadInModal(customData: CustomData): Promise\<void>
28e41f4b71Sopenharmony_ci
29e41f4b71Sopenharmony_ciStarts a modal page.
30e41f4b71Sopenharmony_ci
31e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
32e41f4b71Sopenharmony_ci
33e41f4b71Sopenharmony_ci**Parameters**
34e41f4b71Sopenharmony_ci
35e41f4b71Sopenharmony_ci| Name    | Type                                                     | Mandatory | Description                        |
36e41f4b71Sopenharmony_ci| ---------- | --------------------------------------------------------- | ---- | ---------------------------- |
37e41f4b71Sopenharmony_ci| customData | [CustomData](js-apis-inner-application-customData-sys.md) | Yes  | Custom information for starting the modal page. |
38e41f4b71Sopenharmony_ci
39e41f4b71Sopenharmony_ci**Return value**
40e41f4b71Sopenharmony_ci
41e41f4b71Sopenharmony_ci| Type               | Description                     |
42e41f4b71Sopenharmony_ci| ------------------- | ------------------------- |
43e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | Promise that returns no value. |
44e41f4b71Sopenharmony_ci
45e41f4b71Sopenharmony_ci**Error codes**
46e41f4b71Sopenharmony_ci
47e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Ability Error Codes](errorcode-ability.md).
48e41f4b71Sopenharmony_ci
49e41f4b71Sopenharmony_ci| ID | Error Message                                                    |
50e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ |
51e41f4b71Sopenharmony_ci| 202      | Not System App. Interface caller is not a system app.        |
52e41f4b71Sopenharmony_ci| 401      | If the input parameter is not valid parameter.               |
53e41f4b71Sopenharmony_ci| 16000011 | The context does not exist.                                  |
54e41f4b71Sopenharmony_ci| 16000050 | Internal error.                                              |
55e41f4b71Sopenharmony_ci
56e41f4b71Sopenharmony_ci**Example**
57e41f4b71Sopenharmony_ci
58e41f4b71Sopenharmony_ciThe autofill service is triggered when a user touches the account and password text box, and an account selection page is displayed in the **onFillRequest** lifecycle of the [AutoFillExtensionAbility](js-apis-app-ability-autoFillExtensionAbility-sys.md).
59e41f4b71Sopenharmony_ci
60e41f4b71Sopenharmony_ciWhen an account is selected, **reloadInModal** is called to trigger the autofill service again, and a modal page is started in the** onFillRequest** lifecycle of the AutoFillExtensionAbility.
61e41f4b71Sopenharmony_ci
62e41f4b71Sopenharmony_ci```ts
63e41f4b71Sopenharmony_ci// AutoFillAbility.ts
64e41f4b71Sopenharmony_ciimport { AutoFillExtensionAbility, autoFillManager, UIExtensionContentSession } from '@kit.AbilityKit';
65e41f4b71Sopenharmony_ciimport { hilog } from '@kit.PerformanceAnalysisKit';
66e41f4b71Sopenharmony_ci
67e41f4b71Sopenharmony_ciexport default class AutoFillAbility extends AutoFillExtensionAbility {
68e41f4b71Sopenharmony_ci  // ...
69e41f4b71Sopenharmony_ci  onFillRequest(session: UIExtensionContentSession,
70e41f4b71Sopenharmony_ci                request: autoFillManager.FillRequest,
71e41f4b71Sopenharmony_ci                callback: autoFillManager.FillRequestCallback) {
72e41f4b71Sopenharmony_ci    hilog.info(0x0000, 'testTag', '%{public}s', 'autofill onFillRequest');
73e41f4b71Sopenharmony_ci    try {
74e41f4b71Sopenharmony_ci      let storage_fill: LocalStorage = new LocalStorage(
75e41f4b71Sopenharmony_ci        {
76e41f4b71Sopenharmony_ci          'session': session,
77e41f4b71Sopenharmony_ci          'message': "AutoFill Page",
78e41f4b71Sopenharmony_ci          'fillCallback': callback,
79e41f4b71Sopenharmony_ci          'viewData': request.viewData,
80e41f4b71Sopenharmony_ci          'autoFillExtensionContext': this.context,
81e41f4b71Sopenharmony_ci          'customData': request.customData
82e41f4b71Sopenharmony_ci        });
83e41f4b71Sopenharmony_ci      if (request.customData == undefined) {
84e41f4b71Sopenharmony_ci        // Load the autofill processing page.
85e41f4b71Sopenharmony_ci        session.loadContent('pages/AccountPage', storage_fill);
86e41f4b71Sopenharmony_ci      } else {
87e41f4b71Sopenharmony_ci        // Start a modal page.
88e41f4b71Sopenharmony_ci        session.loadContent('pages/ReloadInModal', storage_fill);
89e41f4b71Sopenharmony_ci      }
90e41f4b71Sopenharmony_ci    } catch (err) {
91e41f4b71Sopenharmony_ci      hilog.error(0x0000, 'testTag', '%{public}s', 'autofill failed to load content');
92e41f4b71Sopenharmony_ci    }
93e41f4b71Sopenharmony_ci  }
94e41f4b71Sopenharmony_ci}
95e41f4b71Sopenharmony_ci```
96e41f4b71Sopenharmony_ci
97e41f4b71Sopenharmony_ciWhen the user selects an account on the account selection page, the **reloadInModal** API is called.
98e41f4b71Sopenharmony_ci
99e41f4b71Sopenharmony_ci```ts
100e41f4b71Sopenharmony_ci// AccountPage.ets
101e41f4b71Sopenharmony_ciimport { autoFillManager, common } from '@kit.AbilityKit';
102e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
103e41f4b71Sopenharmony_ci
104e41f4b71Sopenharmony_cilet storage: LocalStorage = LocalStorage.getShared();
105e41f4b71Sopenharmony_cilet viewData: autoFillManager.ViewData | undefined = storage.get<autoFillManager.ViewData>('viewData');
106e41f4b71Sopenharmony_cilet context: common.AutoFillExtensionContext | undefined = storage.get<common.AutoFillExtensionContext>('autoFillExtensionContext');
107e41f4b71Sopenharmony_ci
108e41f4b71Sopenharmony_ci@Entry
109e41f4b71Sopenharmony_ci@Component
110e41f4b71Sopenharmony_cistruct AccountPage {
111e41f4b71Sopenharmony_ci  build() {
112e41f4b71Sopenharmony_ci    Row() {
113e41f4b71Sopenharmony_ci      Column() {
114e41f4b71Sopenharmony_ci        List({ space: 10, initialIndex: 0 }) {
115e41f4b71Sopenharmony_ci          ListItem() {
116e41f4b71Sopenharmony_ci            Text('HelloWorld789456')
117e41f4b71Sopenharmony_ci              .width('100%')
118e41f4b71Sopenharmony_ci              .height(40)
119e41f4b71Sopenharmony_ci              .fontSize(16)
120e41f4b71Sopenharmony_ci              .textAlign(TextAlign.Center)
121e41f4b71Sopenharmony_ci              .borderRadius(5)
122e41f4b71Sopenharmony_ci          }
123e41f4b71Sopenharmony_ci          .onClick(() => {
124e41f4b71Sopenharmony_ci            if (viewData != undefined) {
125e41f4b71Sopenharmony_ci              if (context != undefined) {
126e41f4b71Sopenharmony_ci                context.reloadInModal({ data: { viewData: 20, text: 'HelloWorld789456' } }).then(() => {
127e41f4b71Sopenharmony_ci                  console.info('reloadInModal successfully.')
128e41f4b71Sopenharmony_ci                }).catch((err: BusinessError) => {
129e41f4b71Sopenharmony_ci                  console.error('reloadInModal failed.')
130e41f4b71Sopenharmony_ci                })
131e41f4b71Sopenharmony_ci              }
132e41f4b71Sopenharmony_ci            }
133e41f4b71Sopenharmony_ci          })
134e41f4b71Sopenharmony_ci        }
135e41f4b71Sopenharmony_ci        // ...
136e41f4b71Sopenharmony_ci      }
137e41f4b71Sopenharmony_ci      .width('100%')
138e41f4b71Sopenharmony_ci      .shadow(ShadowStyle.OUTER_FLOATING_SM)
139e41f4b71Sopenharmony_ci    }
140e41f4b71Sopenharmony_ci    .height('100%')
141e41f4b71Sopenharmony_ci    .shadow(ShadowStyle.OUTER_FLOATING_SM)
142e41f4b71Sopenharmony_ci  }
143e41f4b71Sopenharmony_ci}
144e41f4b71Sopenharmony_ci```
145