• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# @ohos.app.form.formHost (FormHost)
2
3The **FormHost** module provides APIs related to the widget host, which is an application that displays the widget content and controls the position where the widget is displayed. You can use the APIs to delete, release, and update widgets installed by the same user, and obtain widget information and status.
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> The APIs provided by this module are system APIs.
9
10## Modules to Import
11
12```ts
13import formHost from '@ohos.app.form.formHost';
14```
15
16## deleteForm
17
18deleteForm(formId: string, callback: AsyncCallback<void>): void
19
20Deletes a widget. After this API is called, the application can no longer use the widget, and the Widget Manager will not retain the widget information. This API uses an asynchronous callback to return the result.
21
22**Required permissions**: ohos.permission.REQUIRE_FORM
23
24**System capability**: SystemCapability.Ability.Form
25
26**Parameters**
27
28| Name| Type   | Mandatory| Description   |
29| ------ | ------ | ---- | ------- |
30| formId | string | Yes  | Widget ID.|
31| callback | AsyncCallback<void> | Yes| Callback used to return the result. If the widget is deleted, **error** is undefined; otherwise, **error** is an error object.|
32
33**Error codes**
34
35| Error Code ID| Error Message|
36| -------- | -------- |
37| 401 | If the input parameter is not valid parameter. |
38|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
39
40**Example**
41
42```ts
43try {
44  var formId = '12400633174999288';
45  formHost.deleteForm(formId, (error, data) => {
46  if (error) {
47    console.log('formHost deleteForm, error:' + JSON.stringify(error));
48  } else {
49    console.log('formHost deleteForm success');
50  }
51  });
52} catch (error) {
53  console.log(`catch err->${JSON.stringify(error)}`);
54}
55
56```
57
58## deleteForm
59
60deleteForm(formId: string): Promise<void>
61
62Deletes a widget. After this API is called, the application can no longer use the widget, and the Widget Manager will not retain the widget information. This API uses a promise to return the result.
63
64**Required permissions**: ohos.permission.REQUIRE_FORM
65
66**System capability**: SystemCapability.Ability.Form
67
68**Parameters**
69
70| Name| Type   | Mandatory| Description   |
71| ------ | ------ | ---- | ------- |
72| formId | string | Yes  | Widget ID.|
73
74**Return value**
75
76| Type| Description|
77| -------- | -------- |
78| Promise<void> | Promise that returns no value.|
79
80
81**Error codes**
82
83| Error Code ID| Error Message|
84| -------- | -------- |
85| 401 | If the input parameter is not valid parameter. |
86|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
87
88**Parameters**
89
90```ts
91try {
92  var formId = '12400633174999288';
93  formHost.deleteForm(formId).then(() => {
94    console.log('formHost deleteForm success');
95  }).catch((error) => {
96    console.log('formHost deleteForm, error:' + JSON.stringify(error));
97  });
98} catch(error) {
99  console.log(`catch err->${JSON.stringify(error)}`);
100}
101```
102
103## releaseForm
104
105releaseForm(formId: string, callback: AsyncCallback<void>): void
106
107Releases a widget. After this API is called, the application can no longer use the widget, but the Widget Manager still retains the widget cache and storage information. This API uses an asynchronous callback to return the result.
108
109**Required permissions**: ohos.permission.REQUIRE_FORM
110
111**System capability**: SystemCapability.Ability.Form
112
113**Parameters**
114
115| Name| Type   | Mandatory| Description   |
116| ------ | ------ | ---- | ------- |
117| formId | string | Yes  | Widget ID.|
118| callback | AsyncCallback<void> | Yes| Callback used to return the result. If the widget is released, **error** is undefined; otherwise, **error** is an error object.|
119
120**Error codes**
121
122| Error Code ID| Error Message|
123| -------- | -------- |
124| 401 | If the input parameter is not valid parameter. |
125|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
126
127**Example**
128
129```ts
130try {
131  var formId = '12400633174999288';
132  formHost.releaseForm(formId, (error, data) => {
133    if (error) {
134      console.log('formHost releaseForm, error:' + JSON.stringify(error));
135    }
136  });
137} catch(error) {
138    console.log(`catch err->${JSON.stringify(error)}`);
139}
140```
141
142## releaseForm
143
144releaseForm(formId: string, isReleaseCache: boolean, callback: AsyncCallback<void>): void
145
146Releases a widget. After this API is called, the application can no longer use the widget, but the Widget Manager retains the storage information about the widget and retains or releases the cache information based on the setting. This API uses an asynchronous callback to return the result.
147
148**Required permissions**: ohos.permission.REQUIRE_FORM
149
150**System capability**: SystemCapability.Ability.Form
151
152**Parameters**
153
154| Name        | Type    | Mandatory| Description       |
155| -------------- | ------  | ---- | ----------- |
156| formId         | string  | Yes  | Widget ID.    |
157| isReleaseCache | boolean | Yes  | Whether to release the cache.|
158| callback | AsyncCallback<void> | Yes| Callback used to return the result. If the widget is released, **error** is undefined; otherwise, **error** is an error object.|
159
160**Error codes**
161
162| Error Code ID| Error Message|
163| -------- | -------- |
164| 401 | If the input parameter is not valid parameter. |
165|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
166
167**Example**
168
169```ts
170try {
171  var formId = '12400633174999288';
172  formHost.releaseForm(formId, true, (error, data) => {
173    if (error) {
174      console.log('formHost releaseForm, error:' + JSON.stringify(error));
175    }
176  });
177} catch(error) {
178    console.log(`catch err->${JSON.stringify(error)}`);
179}
180```
181
182## releaseForm
183
184releaseForm(formId: string, isReleaseCache?: boolean): Promise<void>
185
186Releases a widget. After this API is called, the application can no longer use the widget, but the Widget Manager retains the storage information about the widget and retains or releases the cache information based on the setting. This API uses a promise to return the result.
187
188**Required permissions**: ohos.permission.REQUIRE_FORM
189
190**System capability**: SystemCapability.Ability.Form
191
192**Parameters**
193
194| Name        | Type    | Mandatory| Description       |
195| -------------- | ------  | ---- | ----------- |
196| formId         | string  | Yes  | Widget ID.    |
197| isReleaseCache | boolean | No  | Whether to release the cache.|
198
199**Return value**
200
201| Type| Description|
202| -------- | -------- |
203| Promise<void> | Promise that returns no value.|
204
205**Error codes**
206
207| Error Code ID| Error Message|
208| -------- | -------- |
209| 401 | If the input parameter is not valid parameter. |
210|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
211
212**Example**
213
214```ts
215try {
216  var formId = '12400633174999288';
217  formHost.releaseForm(formId, true).then(() => {
218    console.log('formHost releaseForm success');
219  }).catch((error) => {
220    console.log('formHost releaseForm, error:' + JSON.stringify(error));
221  });
222} catch(error) {
223    console.log(`catch err->${JSON.stringify(error)}`);
224}
225```
226
227## requestForm
228
229requestForm(formId: string, callback: AsyncCallback<void>): void
230
231Requests a widget update. This API uses an asynchronous callback to return the result.
232
233**Required permissions**: ohos.permission.REQUIRE_FORM
234
235**System capability**: SystemCapability.Ability.Form
236
237**Parameters**
238
239| Name| Type   | Mandatory| Description   |
240| ------ | ------ | ---- | ------- |
241| formId | string | Yes  | Widget ID.|
242| callback | AsyncCallback<void> | Yes| Callback used to return the result. If the widget is updated, **error** is undefined; otherwise, **error** is an error object.|
243
244**Error codes**
245
246| Error Code ID| Error Message|
247| -------- | -------- |
248| 401 | If the input parameter is not valid parameter. |
249|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
250
251**Example**
252
253```ts
254try {
255  var formId = '12400633174999288';
256  formHost.requestForm(formId, (error, data) => {
257    if (error) {
258      console.log('formHost requestForm, error:' + JSON.stringify(error));
259    }
260  });
261} catch(error) {
262    console.log(`catch err->${JSON.stringify(error)}`);
263}
264```
265
266## requestForm
267
268requestForm(formId: string): Promise<void>
269
270Requests a widget update. This API uses a promise to return the result.
271
272**Required permissions**: ohos.permission.REQUIRE_FORM
273
274**System capability**: SystemCapability.Ability.Form
275
276**Parameters**
277
278| Name| Type   | Mandatory| Description   |
279| ------ | ------ | ---- | ------- |
280| formId | string | Yes  | Widget ID.|
281
282**Return value**
283
284| Type| Description|
285| -------- | -------- |
286| Promise<void> | Promise that returns no value.|
287
288**Error codes**
289
290| Error Code ID| Error Message|
291| -------- | -------- |
292| 401 | If the input parameter is not valid parameter. |
293|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
294
295**Example**
296
297```ts
298try {
299  var formId = '12400633174999288';
300  formHost.requestForm(formId).then(() => {
301    console.log('formHost requestForm success');
302  }).catch((error) => {
303    console.log('formHost requestForm, error:' + JSON.stringify(error));
304  });
305} catch(error) {
306    console.log(`catch err->${JSON.stringify(error)}`);
307}
308
309```
310
311## castToNormalForm
312
313castToNormalForm(formId: string, callback: AsyncCallback<void>): void
314
315Converts a temporary widget to a normal one. This API uses an asynchronous callback to return the result.
316
317**Required permissions**: ohos.permission.REQUIRE_FORM
318
319**System capability**: SystemCapability.Ability.Form
320
321**Parameters**
322
323| Name| Type   | Mandatory| Description   |
324| ------ | ------ | ---- | ------- |
325| formId | string | Yes  | Widget ID.|
326| callback | AsyncCallback<void> | Yes| Callback used to return the result. If the widget is converted to a normal one, **error** is undefined; otherwise, **error** is an error object.|
327
328**Error codes**
329
330| Error Code ID| Error Message|
331| -------- | -------- |
332| 401 | If the input parameter is not valid parameter. |
333|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
334
335**Example**
336
337```ts
338try {
339  var formId = '12400633174999288';
340  formHost.castToNormalForm(formId, (error, data) => {
341    if (error) {
342      console.log('formHost castTempForm, error:' + JSON.stringify(error));
343    }
344  });
345} catch(error) {
346    console.log(`catch err->${JSON.stringify(error)}`);
347}
348```
349
350## castToNormalForm
351
352castToNormalForm(formId: string): Promise<void>
353
354Converts a temporary widget to a normal one. This API uses a promise to return the result.
355
356**Required permissions**: ohos.permission.REQUIRE_FORM
357
358**System capability**: SystemCapability.Ability.Form
359
360**Parameters**
361
362| Name| Type   | Mandatory| Description   |
363| ------ | ------ | ---- | ------- |
364| formId | string | Yes  | Widget ID.|
365
366**Return value**
367
368| Type| Description|
369| -------- | -------- |
370| Promise<void> | Promise that returns no value.|
371
372**Error codes**
373
374| Error Code ID| Error Message|
375| -------- | -------- |
376| 401 | If the input parameter is not valid parameter. |
377|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
378
379**Example**
380
381```ts
382try {
383  var formId = '12400633174999288';
384  formHost.castToNormalForm(formId).then(() => {
385    console.log('formHost castTempForm success');
386  }).catch((error) => {
387    console.log('formHost castTempForm, error:' + JSON.stringify(error));
388  });
389} catch(error) {
390    console.log(`catch err->${JSON.stringify(error)}`);
391}
392```
393
394## notifyVisibleForms
395
396notifyVisibleForms(formIds: Array<string>, callback: AsyncCallback<void>): void
397
398Instructs the widget framework to make a widget visible. After this API is called, **onVisibilityChange** is invoked to notify the widget provider. This API uses an asynchronous callback to return the result.
399
400**Required permissions**: ohos.permission.REQUIRE_FORM
401
402**System capability**: SystemCapability.Ability.Form
403
404**Parameters**
405
406| Name| Type   | Mandatory| Description   |
407| ------ | ------ | ---- | ------- |
408| formIds  | Array<string>       | Yes  | List of widget IDs.        |
409| callback | AsyncCallback<void> | Yes| Callback used to return the result. If a notification is sent to the widget framework to make the widget visible, **error** is undefined; otherwise, **error** is an error object.|
410
411**Error codes**
412
413| Error Code ID| Error Message|
414| -------- | -------- |
415| 401 | If the input parameter is not valid parameter. |
416|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
417
418**Example**
419
420```ts
421try {
422  var formId = ['12400633174999288'];
423  formHost.notifyVisibleForms(formId, (error, data) => {
424    if (error) {
425      console.log('formHost notifyVisibleForms, error:' + JSON.stringify(error));
426    }
427  });
428} catch(error) {
429    console.log(`catch err->${JSON.stringify(error)}`);
430}
431```
432
433## notifyVisibleForms
434
435notifyVisibleForms(formIds: Array<string>): Promise<void>
436
437Instructs the widget framework to make a widget visible. After this API is called, **onVisibilityChange** is invoked to notify the widget provider. This API uses a promise to return the result.
438
439**Required permissions**: ohos.permission.REQUIRE_FORM
440
441**System capability**: SystemCapability.Ability.Form
442
443**Parameters**
444
445| Name| Type   | Mandatory| Description   |
446| ------ | ------ | ---- | ------- |
447| formIds | Array<string> | Yes  | List of widget IDs.|
448
449**Return value**
450
451| Type| Description|
452| -------- | -------- |
453| Promise<void> | Promise that returns no value.|
454
455**Error codes**
456
457| Error Code ID| Error Message|
458| -------- | -------- |
459| 401 | If the input parameter is not valid parameter. |
460|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
461
462**Example**
463
464```ts
465try {
466  var formId = ['12400633174999288'];
467  formHost.notifyVisibleForms(formId).then(() => {
468    console.log('formHost notifyVisibleForms success');
469  }).catch((error) => {
470    console.log('formHost notifyVisibleForms, error:' + JSON.stringify(error));
471  });
472} catch(error) {
473    console.log(`catch err->${JSON.stringify(error)}`);
474}
475```
476
477## notifyInvisibleForms
478
479notifyInvisibleForms(formIds: Array<string>, callback: AsyncCallback<void>): void
480
481Instructs the widget framework to make a widget invisible. After this API is called, **onVisibilityChange** is invoked to notify the widget provider. This API uses an asynchronous callback to return the result.
482
483**Required permissions**: ohos.permission.REQUIRE_FORM
484
485**System capability**: SystemCapability.Ability.Form
486
487**Parameters**
488
489| Name| Type   | Mandatory| Description   |
490| ------ | ------ | ---- | ------- |
491| formIds  | Array<string>       | Yes  | List of widget IDs.|
492| callback | AsyncCallback<void> | Yes| Callback used to return the result. If a notification is sent to the widget framework to make the widget invisible, **error** is undefined; otherwise, **error** is an error object.|
493
494**Error codes**
495
496| Error Code ID| Error Message|
497| -------- | -------- |
498| 401 | If the input parameter is not valid parameter. |
499|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
500
501**Example**
502
503```ts
504try {
505  var formId = ['12400633174999288'];
506  formHost.notifyInvisibleForms(formId, (error, data) => {
507    if (error) {
508      console.log('formHost notifyInvisibleForms, error:' + JSON.stringify(error));
509    }
510  });
511} catch(error) {
512    console.log(`catch err->${JSON.stringify(error)}`);
513}
514```
515
516## notifyInvisibleForms
517
518notifyInvisibleForms(formIds: Array<string>): Promise<void>
519
520Instructs the widget framework to make a widget invisible. After this API is called, **onVisibilityChange** is invoked to notify the widget provider. This API uses a promise to return the result.
521
522**Required permissions**: ohos.permission.REQUIRE_FORM
523
524**System capability**: SystemCapability.Ability.Form
525
526**Parameters**
527
528| Name| Type   | Mandatory| Description   |
529| ------ | ------ | ---- | ------- |
530| formIds | Array<string> | Yes  | List of widget IDs.|
531
532**Return value**
533
534| Type| Description|
535| -------- | -------- |
536| Promise<void> | Promise that returns no value.|
537
538**Error codes**
539
540| Error Code ID| Error Message|
541| -------- | -------- |
542| 401 | If the input parameter is not valid parameter. |
543|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
544
545**Example**
546
547```ts
548try {
549  var formId = ['12400633174999288'];
550  formHost.notifyInvisibleForms(formId).then(() => {
551    console.log('formHost notifyInvisibleForms success');
552  }).catch((error) => {
553    console.log('formHost notifyInvisibleForms, error:' + JSON.stringify(error));
554  });
555} catch(error) {
556    console.log(`catch err->${JSON.stringify(error)}`);
557}
558```
559
560## enableFormsUpdate
561
562enableFormsUpdate(formIds: Array<string>, callback: AsyncCallback<void>): void
563
564Instructs the widget framework to make a widget updatable. After this API is called, the widget is in the enabled state and can receive updates from the widget provider. This API uses an asynchronous callback to return the result.
565
566**Required permissions**: ohos.permission.REQUIRE_FORM
567
568**System capability**: SystemCapability.Ability.Form
569
570**Parameters**
571
572| Name| Type   | Mandatory| Description   |
573| ------ | ------ | ---- | ------- |
574| formIds  | Array<string>       | Yes  | List of widget IDs.        |
575| callback | AsyncCallback<void> | Yes| Callback used to return the result. If a notification is sent to the widget framework to make the widget updatable, **error** is undefined; otherwise, **error** is an error object.|
576
577**Error codes**
578
579| Error Code ID| Error Message|
580| -------- | -------- |
581| 401 | If the input parameter is not valid parameter. |
582|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
583
584**Example**
585
586```ts
587try {
588  var formId = ['12400633174999288'];
589  formHost.enableFormsUpdate(formId, (error, data) => {
590    if (error) {
591      console.log('formHost enableFormsUpdate, error:' + JSON.stringify(error));
592    }
593  });
594} catch(error) {
595    console.log(`catch err->${JSON.stringify(error)}`);
596}
597```
598
599## enableFormsUpdate
600
601enableFormsUpdate(formIds: Array<string>): Promise<void>
602
603Instructs the widget framework to make a widget updatable. After this API is called, the widget is in the enabled state and can receive updates from the widget provider. This API uses a promise to return the result.
604
605**Required permissions**: ohos.permission.REQUIRE_FORM
606
607**System capability**: SystemCapability.Ability.Form
608
609**Parameters**
610
611| Name| Type   | Mandatory| Description   |
612| ------ | ------ | ---- | ------- |
613| formIds | Array<string> | Yes  | List of widget IDs.|
614
615**Return value**
616
617| Type| Description|
618| -------- | -------- |
619| Promise<void> | Promise that returns no value.|
620
621**Error codes**
622
623| Error Code ID| Error Message|
624| -------- | -------- |
625| 401 | If the input parameter is not valid parameter. |
626|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
627
628**Example**
629
630```ts
631try {
632  var formId = ['12400633174999288'];
633  formHost.enableFormsUpdate(formId).then(() => {
634    console.log('formHost enableFormsUpdate success');
635  }).catch((error) => {
636    console.log('formHost enableFormsUpdate, error:' + JSON.stringify(error));
637  });
638} catch(error) {
639    console.log(`catch err->${JSON.stringify(error)}`);
640}
641```
642
643## disableFormsUpdate
644
645disableFormsUpdate(formIds: Array<string>, callback: AsyncCallback<void>): void
646
647Instructs the widget framework to make a widget not updatable. After this API is called, the widget cannot receive updates from the widget provider. This API uses an asynchronous callback to return the result.
648
649**Required permissions**: ohos.permission.REQUIRE_FORM
650
651**System capability**: SystemCapability.Ability.Form
652
653**Parameters**
654
655| Name| Type   | Mandatory| Description   |
656| ------ | ------ | ---- | ------- |
657| formIds  | Array<string>       | Yes  | List of widget IDs.        |
658| callback | AsyncCallback<void> | Yes| Callback used to return the result. If a notification is sent to the widget framework to make the widget not updatable, **error** is undefined; otherwise, **error** is an error object.|
659
660**Error codes**
661
662| Error Code ID| Error Message|
663| -------- | -------- |
664| 401 | If the input parameter is not valid parameter. |
665|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
666
667**Example**
668
669```ts
670try {
671  var formId = ['12400633174999288'];
672  formHost.disableFormsUpdate(formId, (error, data) => {
673    if (error) {
674      console.log('formHost disableFormsUpdate, error:' + JSON.stringify(error));
675    }
676  });
677} catch(error) {
678    console.log(`catch err->${JSON.stringify(error)}`);
679}
680```
681
682## disableFormsUpdate
683
684disableFormsUpdate(formIds: Array<string>): Promise<void>
685
686Instructs the widget framework to make a widget not updatable. After this API is called, the widget cannot receive updates from the widget provider. This API uses a promise to return the result.
687
688**Required permissions**: ohos.permission.REQUIRE_FORM
689
690**System capability**: SystemCapability.Ability.Form
691
692**Parameters**
693
694| Name| Type   | Mandatory| Description   |
695| ------ | ------ | ---- | ------- |
696| formIds | Array<string> | Yes  | List of widget IDs.|
697
698**Return value**
699
700| Type| Description|
701| -------- | -------- |
702| Promise<void> | Promise that returns no value.|
703
704**Error codes**
705
706| Error Code ID| Error Message|
707| -------- | -------- |
708| 401 | If the input parameter is not valid parameter. |
709|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
710
711**Example**
712
713```ts
714try {
715  var formId = ['12400633174999288'];
716  formHost.disableFormsUpdate(formId).then(() => {
717    console.log('formHost disableFormsUpdate success');
718  }).catch((error) => {
719    console.log('formHost disableFormsUpdate, error:' + JSON.stringify(error));
720  });
721} catch(error) {
722    console.log(`catch err->${JSON.stringify(error)}`);
723}
724```
725
726## isSystemReady
727
728isSystemReady(callback: AsyncCallback<void>): void
729
730Checks whether the system is ready. This API uses an asynchronous callback to return the result.
731
732**System capability**: SystemCapability.Ability.Form
733
734**Parameters**
735
736| Name| Type   | Mandatory| Description   |
737| ------ | ------ | ---- | ------- |
738| callback | AsyncCallback<void> | Yes| Callback used to return the result. If the check is successful, **error** is undefined; otherwise, **error** is an error object.|
739
740**Example**
741
742```ts
743try {
744  var formId = '12400633174999288';
745  formHost.isSystemReady((error, data) => {
746    if (error) {
747      console.log('formHost isSystemReady, error:' + JSON.stringify(error));
748    }
749  });
750} catch(error) {
751    console.log(`catch err->${JSON.stringify(error)}`);
752}
753```
754
755## isSystemReady
756
757isSystemReady(): Promise<void>
758
759Checks whether the system is ready. This API uses a promise to return the result.
760
761**System capability**: SystemCapability.Ability.Form
762
763**Return value**
764
765| Type| Description|
766| -------- | -------- |
767| Promise<void> | Promise that returns no value.|
768
769**Example**
770
771```ts
772try {
773  var formId = '12400633174999288';
774  formHost.isSystemReady().then(() => {
775    console.log('formHost isSystemReady success');
776  }).catch((error) => {
777    console.log('formHost isSystemReady, error:' + JSON.stringify(error));
778  });
779} catch(error) {
780    console.log(`catch err->${JSON.stringify(error)}`);
781}
782```
783
784## getAllFormsInfo
785
786getAllFormsInfo(callback: AsyncCallback<Array<formInfo.FormInfo>>): void
787
788Obtains the widget information provided by all applications on the device. This API uses an asynchronous callback to return the result.
789
790**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
791
792**System capability**: SystemCapability.Ability.Form
793
794**Parameters**
795
796| Name| Type   | Mandatory| Description   |
797| ------ | ------ | ---- | ------- |
798| callback | AsyncCallback<Array<[FormInfo](js-apis-app-form-formInfo.md)>> | Yes| Callback used to return the result. If the widget information is obtained, **error** is undefined and **data** is the information obtained; otherwise, **error** is an error object.|
799
800**Example**
801
802```ts
803try {
804  formHost.getAllFormsInfo((error, data) => {
805    if (error) {
806      console.log('formHost getAllFormsInfo, error:' + JSON.stringify(error));
807    } else {
808      console.log('formHost getAllFormsInfo, data:' + JSON.stringify(data));
809    }
810  });
811} catch(error) {
812    console.log(`catch err->${JSON.stringify(error)}`);
813}
814```
815
816## getAllFormsInfo
817
818getAllFormsInfo(): Promise<Array<formInfo.FormInfo>>
819
820Obtains the widget information provided by all applications on the device. This API uses a promise to return the result.
821
822**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
823
824**System capability**: SystemCapability.Ability.Form
825
826**Return value**
827
828| Type                                                        | Description                               |
829| :----------------------------------------------------------- | :---------------------------------- |
830| Promise<Array<[FormInfo](js-apis-app-form-formInfo.md)>> | Promise used to return the information obtained.|
831
832**Example**
833
834```ts
835try {
836  formHost.getAllFormsInfo().then((data) => {
837      console.log('formHost getAllFormsInfo data:' + JSON.stringify(data));
838  }).catch((error) => {
839      console.log('formHost getAllFormsInfo, error:' + JSON.stringify(error));
840  });
841} catch(error) {
842    console.log(`catch err->${JSON.stringify(error)}`);
843}
844```
845
846## getFormsInfo
847
848getFormsInfo(bundleName: string, callback: AsyncCallback<Array<formInfo.FormInfo>>): void
849
850Obtains the widget information provided by a given application on the device. This API uses an asynchronous callback to return the result.
851
852**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
853
854**System capability**: SystemCapability.Ability.Form
855
856**Parameters**
857
858| Name| Type   | Mandatory| Description   |
859| ------ | ------ | ---- | ------- |
860| bundleName | string | Yes| Bundle name of the application.|
861| callback | AsyncCallback<Array<[formInfo.FormInfo](js-apis-app-form-formInfo.md)>> | Yes| Callback used to return the result. If the widget information is obtained, **error** is undefined and **data** is the information obtained; otherwise, **error** is an error object.|
862
863**Error codes**
864
865| Error Code ID| Error Message|
866| -------- | -------- |
867| 401 | If the input parameter is not valid parameter. |
868|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
869
870**Example**
871
872```ts
873try {
874  formHost.getFormsInfo('com.example.ohos.formjsdemo', (error, data) => {
875    if (error) {
876      console.log('formHost getFormsInfo, error:' + JSON.stringify(error));
877    } else {
878      console.log('formHost getFormsInfo, data:' + JSON.stringify(data));
879    }
880  });
881} catch(error) {
882    console.log(`catch err->${JSON.stringify(error)}`);
883}
884```
885
886## getFormsInfo
887
888getFormsInfo(bundleName: string, moduleName: string, callback: AsyncCallback<Array<formInfo.FormInfo>>): void
889
890Obtains the widget information provided by a given application on the device. This API uses an asynchronous callback to return the result.
891
892**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
893
894**System capability**: SystemCapability.Ability.Form
895
896**Parameters**
897
898| Name| Type   | Mandatory| Description   |
899| ------ | ------ | ---- | ------- |
900| bundleName | string | Yes| Bundle name of the application.|
901| moduleName | string | Yes|  Module name.|
902| callback | AsyncCallback<Array<[formInfo.FormInfo](js-apis-app-form-formInfo.md)>> | Yes| Callback used to return the result. If the widget information is obtained, **error** is undefined and **data** is the information obtained; otherwise, **error** is an error object.|
903
904**Error codes**
905
906| Error Code ID| Error Message|
907| -------- | -------- |
908| 401 | If the input parameter is not valid parameter. |
909|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
910
911**Example**
912
913```ts
914try {
915  formHost.getFormsInfo('com.example.ohos.formjsdemo', 'entry', (error, data) => {
916    if (error) {
917        console.log('formHost getFormsInfo, error:' + JSON.stringify(error));
918    } else {
919        console.log('formHost getFormsInfo, data:' + JSON.stringify(data));
920    }
921  });
922} catch(error) {
923    console.log(`catch err->${JSON.stringify(error)}`);
924}
925```
926
927## getFormsInfo
928
929getFormsInfo(bundleName: string, moduleName?: string): Promise<Array<formInfo.FormInfo>>
930
931Obtains the widget information provided by a given application on the device. This API uses a promise to return the result.
932
933**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
934
935**System capability**: SystemCapability.Ability.Form
936
937**Parameters**
938
939| Name| Type   | Mandatory| Description   |
940| ------ | ------ | ---- | ------- |
941| bundleName | string | Yes| Bundle name of the application.|
942| moduleName | string | No|  Module name.|
943
944**Return value**
945
946| Type                                                        | Description                               |
947| :----------------------------------------------------------- | :---------------------------------- |
948| Promise<Array<[FormInfo](js-apis-app-form-formInfo.md)>> | Promise used to return the information obtained.|
949
950**Error codes**
951
952| Error Code ID| Error Message|
953| -------- | -------- |
954| 401 | If the input parameter is not valid parameter. |
955|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
956
957**Example**
958
959```ts
960try {
961  formHost.getFormsInfo('com.example.ohos.formjsdemo', 'entry').then((data) => {
962    console.log('formHost getFormsInfo, data:' + JSON.stringify(data));
963  }).catch((error) => {
964    console.log('formHost getFormsInfo, error:' + JSON.stringify(error));
965  });
966} catch(error) {
967    console.log(`catch err->${JSON.stringify(error)}`);
968}
969```
970
971## deleteInvalidForms
972
973deleteInvalidForms(formIds: Array<string>, callback: AsyncCallback<number>): void
974
975Deletes invalid widgets from the list. This API uses an asynchronous callback to return the result.
976
977**Required permissions**: ohos.permission.REQUIRE_FORM
978
979**System capability**: SystemCapability.Ability.Form
980
981**Parameters**
982
983| Name| Type   | Mandatory| Description   |
984| ------ | ------ | ---- | ------- |
985| formIds | Array<string> | Yes  | List of valid widget IDs.|
986| callback | AsyncCallback<number> | Yes| Callback used to return the result. If the invalid widgets are deleted, **error** is undefined and **data** is the number of widgets deleted; otherwise, **error** is an error object.|
987
988**Example**
989
990```ts
991try {
992  var formIds = new Array('12400633174999288', '12400633174999289');
993  formHost.deleteInvalidForms(formIds, (error, data) => {
994    if (error) {
995      console.log('formHost deleteInvalidForms, error:' + JSON.stringify(error));
996    } else {
997      console.log('formHost deleteInvalidForms, data:' + JSON.stringify(data));
998    }
999  });
1000} catch(error) {
1001    console.log(`catch err->${JSON.stringify(error)}`);
1002}
1003```
1004
1005## deleteInvalidForms
1006
1007deleteInvalidForms(formIds: Array<string>): Promise<number>
1008
1009Deletes invalid widgets from the list. This API uses a promise to return the result.
1010
1011**Required permissions**: ohos.permission.REQUIRE_FORM
1012
1013**System capability**: SystemCapability.Ability.Form
1014
1015**Parameters**
1016
1017| Name| Type   | Mandatory| Description   |
1018| ------ | ------ | ---- | ------- |
1019| formIds | Array<string> | Yes  | List of valid widget IDs.|
1020
1021**Return value**
1022
1023| Type         | Description                               |
1024| :------------ | :---------------------------------- |
1025| Promise<number> | Promise used to return the number of widgets deleted.|
1026
1027**Example**
1028
1029```ts
1030try {
1031  var formIds = new Array('12400633174999288', '12400633174999289');
1032  formHost.deleteInvalidForms(formIds).then((data) => {
1033    console.log('formHost deleteInvalidForms, data:' + JSON.stringify(data));
1034  }).catch((error) => {
1035    console.log('formHost deleteInvalidForms, error:' + JSON.stringify(error));
1036  });
1037} catch(error) {
1038    console.log(`catch err->${JSON.stringify(error)}`);
1039}
1040```
1041
1042## acquireFormState
1043
1044acquireFormState(want: Want, callback: AsyncCallback<formInfo.FormStateInfo>): void
1045
1046Obtains the widget state. This API uses an asynchronous callback to return the result.
1047
1048**Required permissions**: ohos.permission.REQUIRE_FORM and ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
1049
1050**System capability**: SystemCapability.Ability.Form
1051
1052**Parameters**
1053
1054| Name| Type   | Mandatory| Description   |
1055| ------ | ------ | ---- | ------- |
1056| want | [Want](js-apis-application-want.md) | Yes  | **Want** information carried to query the widget state. The information must contain the bundle name, ability name, module name, widget name, and widget dimensions.|
1057| callback | AsyncCallback<[FormInfo](js-apis-app-form-formInfo.md#formstateinfo)> | Yes| Callback used to return the result. If the widget state is obtained, **error** is undefined and **data** is the widget state obtained; otherwise, **error** is an error object.|
1058
1059**Error codes**
1060
1061| Error Code ID| Error Message|
1062| -------- | -------- |
1063| 401 | If the input parameter is not valid parameter. |
1064|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
1065
1066**Example**
1067
1068```ts
1069var want = {
1070  'deviceId': '',
1071  'bundleName': 'ohos.samples.FormApplication',
1072  'abilityName': 'FormAbility',
1073  'parameters': {
1074    'ohos.extra.param.key.module_name': 'entry',
1075    'ohos.extra.param.key.form_name': 'widget',
1076    'ohos.extra.param.key.form_dimension': 2
1077  }
1078};
1079try {
1080  formHost.acquireFormState(want, (error, data) => {
1081    if (error) {
1082      console.log('formHost acquireFormState, error:' + JSON.stringify(error));
1083    } else {
1084      console.log('formHost acquireFormState, data:' + JSON.stringify(data));
1085    }
1086  });
1087} catch(error) {
1088    console.log(`catch err->${JSON.stringify(error)}`);
1089}
1090```
1091
1092## acquireFormState
1093
1094acquireFormState(want: Want): Promise<formInfo.FormStateInfo>
1095
1096Obtains the widget state. This API uses a promise to return the result.
1097
1098**Required permissions**: ohos.permission.REQUIRE_FORM and ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
1099
1100**System capability**: SystemCapability.Ability.Form
1101
1102**Parameters**
1103
1104| Name| Type   | Mandatory| Description   |
1105| ------ | ------ | ---- | ------- |
1106| want   | [Want](js-apis-application-want.md) | Yes  | **Want** information carried to query the widget state. The information must contain the bundle name, ability name, module name, widget name, and widget dimensions.|
1107
1108**Return value**
1109
1110| Type         | Description                               |
1111| :------------ | :---------------------------------- |
1112| Promise<[FormStateInfo](js-apis-app-form-formInfo.md#formstateinfo)> | Promise used to return the widget state obtained.|
1113
1114**Error codes**
1115
1116| Error Code ID| Error Message|
1117| -------- | -------- |
1118| 401 | If the input parameter is not valid parameter. |
1119|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
1120
1121**Example**
1122
1123```ts
1124var want = {
1125  'deviceId': '',
1126  'bundleName': 'ohos.samples.FormApplication',
1127  'abilityName': 'FormAbility',
1128  'parameters': {
1129    'ohos.extra.param.key.module_name': 'entry',
1130    'ohos.extra.param.key.form_name': 'widget',
1131    'ohos.extra.param.key.form_dimension': 2
1132  }
1133};
1134try {
1135  formHost.acquireFormState(want).then((data) => {
1136    console.log('formHost acquireFormState, data:' + JSON.stringify(data));
1137  }).catch((error) => {
1138    console.log('formHost acquireFormState, error:' + JSON.stringify(error));
1139  });
1140} catch(error) {
1141    console.log(`catch err->${JSON.stringify(error)}`);
1142}
1143```
1144
1145## on('formUninstall')
1146
1147on(type: 'formUninstall', callback: Callback<string>): void
1148
1149Subscribes to widget uninstall events. This API uses an asynchronous callback to return the result.
1150
1151**System capability**: SystemCapability.Ability.Form
1152
1153**Parameters**
1154
1155| Name| Type   | Mandatory| Description   |
1156| ------ | ------ | ---- | ------- |
1157| type | string | Yes  | Event type. The value **'formUninstall'** indicates a widget uninstallation event.|
1158| callback | Callback<string> | Yes| Callback used to return the widget ID.|
1159
1160**Example**
1161
1162```ts
1163let callback = function(formId) {
1164  console.log('formHost on formUninstall, formId:' + formId);
1165}
1166formHost.on('formUninstall', callback);
1167```
1168
1169## off('formUninstall')
1170
1171off(type: 'formUninstall', callback?: Callback<string>): void
1172
1173Unsubscribes from widget uninstall events. This API uses an asynchronous callback to return the result.
1174
1175**System capability**: SystemCapability.Ability.Form
1176
1177**Parameters**
1178
1179| Name| Type   | Mandatory| Description   |
1180| ------ | ------ | ---- | ------- |
1181| type | string | Yes  | Event type. The value **'formUninstall'** indicates a widget uninstallation event.|
1182| callback | Callback&lt;string&gt; | No| Callback used to return the widget ID. If it is left unspecified, it indicates the callback for all the events that have been subscribed.<br> The value must be the same as that in **on('formUninstall')**.|
1183
1184**Example**
1185
1186```ts
1187let callback = function(formId) {
1188  console.log('formHost on formUninstall, formId:' + formId);
1189}
1190formHost.off('formUninstall', callback);
1191```
1192
1193## notifyFormsVisible
1194
1195notifyFormsVisible(formIds: Array&lt;string&gt;, isVisible: boolean, callback: AsyncCallback&lt;void&gt;): void
1196
1197Instructs the widgets to make themselves visible. This API uses an asynchronous callback to return the result.
1198
1199**Required permissions**: ohos.permission.REQUIRE_FORM
1200
1201**System capability**: SystemCapability.Ability.Form
1202
1203**Parameters**
1204
1205| Name| Type   | Mandatory| Description   |
1206| ------ | ------ | ---- | ------- |
1207| formIds | Array&lt;string&gt; | Yes  | List of widget IDs.|
1208| isVisible | boolean | Yes  | Whether to make the widgets visible.|
1209| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result. If the notification is sent, **error** is undefined; otherwise, **error** is an error object.|
1210
1211**Error codes**
1212
1213| Error Code ID| Error Message|
1214| -------- | -------- |
1215| 401 | If the input parameter is not valid parameter. |
1216|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
1217
1218**Example**
1219
1220```ts
1221var formIds = new Array('12400633174999288', '12400633174999289');
1222try {
1223  formHost.notifyFormsVisible(formIds, true, (error, data) => {
1224    if (error) {
1225      console.log('formHost notifyFormsVisible, error:' + JSON.stringify(error));
1226    }
1227  });
1228} catch(error) {
1229    console.log(`catch err->${JSON.stringify(error)}`);
1230}
1231```
1232
1233## notifyFormsVisible
1234
1235notifyFormsVisible(formIds: Array&lt;string&gt;, isVisible: boolean): Promise&lt;void&gt;
1236
1237Instructs the widgets to make themselves visible. This API uses a promise to return the result.
1238
1239**Required permissions**: ohos.permission.REQUIRE_FORM
1240
1241**System capability**: SystemCapability.Ability.Form
1242
1243**Parameters**
1244
1245| Name| Type   | Mandatory| Description   |
1246| ------ | ------ | ---- | ------- |
1247| formIds | Array&lt;string&gt; | Yes  | List of widget IDs.|
1248| isVisible | boolean | Yes  | Whether to make the widgets visible.|
1249
1250**Return value**
1251
1252| Type| Description|
1253| -------- | -------- |
1254| Promise&lt;void&gt; | Promise that returns no value.|
1255
1256**Error codes**
1257
1258| Error Code ID| Error Message|
1259| -------- | -------- |
1260| 401 | If the input parameter is not valid parameter. |
1261|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
1262
1263**Example**
1264
1265```ts
1266var formIds = new Array('12400633174999288', '12400633174999289');
1267try {
1268  formHost.notifyFormsVisible(formIds, true).then(() => {
1269    console.log('formHost notifyFormsVisible success');
1270  }).catch((error) => {
1271    console.log('formHost notifyFormsVisible, error:' + JSON.stringify(error));
1272  });
1273} catch(error) {
1274    console.log(`catch err->${JSON.stringify(error)}`);
1275}
1276```
1277
1278## notifyFormsEnableUpdate
1279
1280notifyFormsEnableUpdate(formIds: Array&lt;string&gt;, isEnableUpdate: boolean, callback: AsyncCallback&lt;void&gt;): void
1281
1282Instructs the widgets to enable or disable updates. This API uses an asynchronous callback to return the result.
1283
1284**Required permissions**: ohos.permission.REQUIRE_FORM
1285
1286**System capability**: SystemCapability.Ability.Form
1287
1288**Parameters**
1289
1290| Name| Type   | Mandatory| Description   |
1291| ------ | ------ | ---- | ------- |
1292| formIds | Array&lt;string&gt; | Yes  | List of widget IDs.|
1293| isEnableUpdate | boolean | Yes  | Whether to make the widgets updatable.|
1294| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result. If the notification is sent, **error** is undefined; otherwise, **error** is an error object.|
1295
1296**Error codes**
1297
1298| Error Code ID| Error Message|
1299| -------- | -------- |
1300| 401 | If the input parameter is not valid parameter. |
1301|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
1302
1303**Example**
1304
1305```ts
1306var formIds = new Array('12400633174999288', '12400633174999289');
1307try {
1308  formHost.notifyFormsEnableUpdate(formIds, true, (error, data) => {
1309    if (error) {
1310      console.log('formHost notifyFormsEnableUpdate, error:' + JSON.stringify(error));
1311    }
1312  });
1313} catch(error) {
1314    console.log(`catch err->${JSON.stringify(error)}`);
1315}
1316```
1317
1318## notifyFormsEnableUpdate
1319
1320notifyFormsEnableUpdate(formIds: Array&lt;string&gt;, isEnableUpdate: boolean): Promise&lt;void&gt;
1321
1322Instructs the widgets to enable or disable updates. This API uses a promise to return the result.
1323
1324**Required permissions**: ohos.permission.REQUIRE_FORM
1325
1326**System capability**: SystemCapability.Ability.Form
1327
1328**Parameters**
1329
1330| Name| Type   | Mandatory| Description   |
1331| ------ | ------ | ---- | ------- |
1332| formIds | Array&lt;string&gt; | Yes  | List of widget IDs.|
1333| isEnableUpdate | boolean | Yes  | Whether to make the widgets updatable.|
1334
1335**Return value**
1336
1337| Type| Description|
1338| -------- | -------- |
1339| Promise&lt;void&gt; | Promise that returns no value.|
1340
1341**Error codes**
1342
1343| Error Code ID| Error Message|
1344| -------- | -------- |
1345| 401 | If the input parameter is not valid parameter. |
1346|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
1347
1348**Example**
1349
1350```ts
1351var formIds = new Array('12400633174999288', '12400633174999289');
1352try {
1353  formHost.notifyFormsEnableUpdate(formIds, true).then(() => {
1354    console.log('formHost notifyFormsEnableUpdate success');
1355  }).catch((error) => {
1356    console.log('formHost notifyFormsEnableUpdate, error:' + JSON.stringify(error));
1357  });
1358} catch(error) {
1359    console.log(`catch err->${JSON.stringify(error)}`);
1360}
1361```
1362## shareForm
1363
1364shareForm(formId: string, deviceId: string, callback: AsyncCallback&lt;void&gt;): void
1365
1366Shares a specified widget with a remote device. This API uses an asynchronous callback to return the result.
1367
1368**Required permissions**: ohos.permission.REQUIRE_FORM and ohos.permission.DISTRIBUTED_DATASYNC
1369
1370**System capability**: SystemCapability.Ability.Form
1371
1372**Parameters**
1373
1374| Name| Type   | Mandatory| Description   |
1375| ------ | ------ | ---- | ------- |
1376| formId | string | Yes  | Widget ID.|
1377| deviceId | string | Yes  | Remote device ID.|
1378| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result. If the widget is shared, **error** is undefined; otherwise, **error** is an error object.|
1379
1380**Error codes**
1381
1382| Error Code ID| Error Message|
1383| -------- | -------- |
1384| 401 | If the input parameter is not valid parameter. |
1385|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
1386
1387
1388**Example**
1389
1390```ts
1391var formId = '12400633174999288';
1392var deviceId = 'EFC11C0C53628D8CC2F8CB5052477E130D075917034613B9884C55CD22B3DEF2';
1393try {
1394  formHost.shareForm(formId, deviceId, (error, data) => {
1395    if (error) {
1396      console.log('formHost shareForm, error:' + JSON.stringify(error));
1397    }
1398  });
1399} catch(error) {
1400    console.log(`catch err->${JSON.stringify(error)}`);
1401}
1402```
1403
1404## shareForm
1405
1406shareForm(formId: string, deviceId: string): Promise&lt;void&gt;
1407
1408Shares a specified widget with a remote device. This API uses a promise to return the result.
1409
1410**Required permissions**: ohos.permission.REQUIRE_FORM and ohos.permission.DISTRIBUTED_DATASYNC
1411
1412**System capability**: SystemCapability.Ability.Form
1413
1414**Parameters**
1415
1416| Name| Type   | Mandatory| Description   |
1417| ------ | ------ | ---- | ------- |
1418| formId | string | Yes  | Widget ID.|
1419| deviceId | string | Yes  | Remote device ID.|
1420
1421**Return value**
1422
1423| Type| Description|
1424| -------- | -------- |
1425| Promise&lt;void&gt; | Promise that returns no value.|
1426
1427**Error codes**
1428
1429| Error Code ID| Error Message|
1430| -------- | -------- |
1431| 401 | If the input parameter is not valid parameter. |
1432|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
1433
1434**Example**
1435
1436```ts
1437var formId = '12400633174999288';
1438var deviceId = 'EFC11C0C53628D8CC2F8CB5052477E130D075917034613B9884C55CD22B3DEF2';
1439try {
1440  formHost.shareForm(formId, deviceId).then(() => {
1441    console.log('formHost shareForm success');
1442  }).catch((error) => {
1443    console.log('formHost shareForm, error:' + JSON.stringify(error));
1444  });
1445} catch(error) {
1446    console.log(`catch err->${JSON.stringify(error)}`);
1447}
1448```
1449
1450## notifyFormsPrivacyProtected
1451
1452notifyFormsPrivacyProtected(formIds: Array\<string>, isProtected: boolean, callback: AsyncCallback\<void>): void
1453
1454Notifies that the privacy protection status of the specified widgets changes. This API uses an asynchronous callback to return the result.
1455
1456**Required permissions**: ohos.permission.REQUIRE_FORM
1457
1458**System capability**: SystemCapability.Ability.Form
1459
1460**Parameters**
1461
1462| Name| Type   | Mandatory| Description   |
1463| ------ | ------ | ---- | ------- |
1464| formId | string | Yes  | Widget ID.|
1465| deviceId | string | Yes   | Remote device ID. |
1466
1467```ts
1468var formIds = new Array('12400633174999288', '12400633174999289');
1469try {
1470  formHost.notifyFormsPrivacyProtected(formIds, true).then(() => {
1471    console.log('formHost shareForm success');
1472  }).catch((error) => {
1473    console.log('formHost shareForm, error:' + JSON.stringify(error));
1474  });
1475} catch(error) {
1476    console.log(`catch err->${JSON.stringify(error)}`);
1477}
1478```
1479