1# FormHost 2 3>  **说明:** 4> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 5 6卡片使用方相关接口。 7 8## 导入模块 9 10``` 11import formHost from '@ohos.application.formHost'; 12``` 13 14## 权限 15 16ohos.permission.REQUIRE_FORM 17 18ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 19 20## deleteForm 21 22deleteForm(formId: string, callback: AsyncCallback<void>): void; 23 24删除指定的卡片。调用此方法后,应用程序将无法使用该卡片,卡片管理器服务不再保留有关该卡片的信息。 25 26**系统能力:** 27 28SystemCapability.Ability.Form 29 30**参数:** 31 32| 参数名 | 类型 | 必填 | 说明 | 33| ------ | ------ | ---- | ------- | 34| formId | string | 是 | 卡片标识 | 35| callback | AsyncCallback<void> | 是 | callback形式返回结果 | 36 37**示例:** 38 39 ```js 40 var formId = "12400633174999288"; 41 formHost.deleteForm(formId, (error, data) => { 42 if (error.code) { 43 console.log('formHost deleteForm, error:' + JSON.stringify(error)); 44 } 45 }); 46 ``` 47 48## deleteForm 49 50deleteForm(formId: string): Promise<void>; 51 52删除指定的卡片。调用此方法后,应用程序将无法使用该卡片,卡片管理器服务不再保留有关该卡片的信息。 53 54**系统能力:** 55 56SystemCapability.Ability.Form 57 58**参数:** 59 60 | 参数名 | 类型 | 必填 | 说明 | 61 | ------ | ------ | ---- | ------- | 62 | formId | string | 是 | 卡片标识 | 63 64**返回值:** 65 66 | 类型 | 说明 | 67 | -------- | -------- | 68 | Promise<void> | 返回一个Promise,包含接口的结果 | 69 70**参数:** 71 72 ```js 73 var formId = "12400633174999288"; 74 formHost.deleteForm(formId).then(() => { 75 console.log('formHost deleteForm success'); 76 }).catch((error) => { 77 console.log('formHost deleteForm, error:' + JSON.stringify(error)); 78 }); 79 ``` 80 81## releaseForm 82 83releaseForm(formId: string, callback: AsyncCallback<void>): void; 84 85释放指定的卡片。调用此方法后,应用程序将无法使用该卡片,但卡片管理器服务仍然保留有关该卡片的缓存信息和存储信息。 86 87**系统能力:** 88 89SystemCapability.Ability.Form 90 91**参数:** 92 93| 参数名 | 类型 | 必填 | 说明 | 94| ------ | ------ | ---- | ------- | 95| formId | string | 是 | 卡片标识 | 96| callback | AsyncCallback<void> | 是 | callback形式返回结果 | 97 98**示例:** 99 100 ```js 101 var formId = "12400633174999288"; 102 formHost.releaseForm(formId, (error, data) => { 103 if (error.code) { 104 console.log('formHost releaseForm, error:' + JSON.stringify(error)); 105 } 106 }); 107 ``` 108 109## releaseForm 110 111releaseForm(formId: string, isReleaseCache: boolean, callback: AsyncCallback<void>): void; 112 113释放指定的卡片。调用此方法后,应用程序将无法使用该卡片,卡片管理器服务保留有关该卡片的存储信息,可以选择是否保留缓存信息。 114 115**系统能力:** 116 117SystemCapability.Ability.Form 118 119**参数:** 120 121| 参数名 | 类型 | 必填 | 说明 | 122| -------------- | ------ | ---- | ----------- | 123| formId | string | 是 | 卡片标识 | 124| isReleaseCache | boolean | 是 | 是否释放缓存 | 125| callback | AsyncCallback<void> | 是 | callback形式返回结果 | 126 127**示例:** 128 129 ```js 130 var formId = "12400633174999288"; 131 formHost.releaseForm(formId, true, (error, data) => { 132 if (error.code) { 133 console.log('formHost releaseForm, error:' + JSON.stringify(error)); 134 } 135 }); 136 ``` 137 138## releaseForm 139 140releaseForm(formId: string, isReleaseCache?: boolean): Promise<void>; 141 142释放指定的卡片。调用此方法后,应用程序将无法使用该卡片,卡片管理器服务保留有关该卡片的存储信息,可以选择是否保留缓存信息。 143 144**系统能力:** 145 146SystemCapability.Ability.Form 147 148**参数:** 149 150 | 参数名 | 类型 | 必填 | 说明 | 151 | -------------- | ------ | ---- | ----------- | 152 | formId | string | 是 | 卡片标识 | 153 | isReleaseCache | boolean | 否 | 是否释放缓存 | 154 155**返回值:** 156 157 | 类型 | 说明 | 158 | -------- | -------- | 159 | Promise<void> | 返回一个Promise,包含接口的结果 | 160 161**示例:** 162 163 ```js 164 var formId = "12400633174999288"; 165 formHost.releaseForm(formId, true).then(() => { 166 console.log('formHost releaseForm success'); 167 }).catch((error) => { 168 console.log('formHost releaseForm, error:' + JSON.stringify(error)); 169 }); 170 ``` 171 172## requestForm 173 174requestForm(formId: string, callback: AsyncCallback<void>): void; 175 176请求卡片更新。 177 178**系统能力:** 179 180SystemCapability.Ability.Form 181 182**参数:** 183 184| 参数名 | 类型 | 必填 | 说明 | 185| ------ | ------ | ---- | ------- | 186| formId | string | 是 | 卡片标识 | 187| callback | AsyncCallback<void> | 是 | callback形式返回结果 | 188 189**示例:** 190 191 ```js 192 var formId = "12400633174999288"; 193 formHost.requestForm(formId, (error, data) => { 194 if (error.code) { 195 console.log('formHost requestForm, error:' + JSON.stringify(error)); 196 } 197 }); 198 ``` 199 200## requestForm 201 202requestForm(formId: string): Promise<void>; 203 204请求卡片更新。 205 206**系统能力:** 207 208SystemCapability.Ability.Form 209 210**参数:** 211 212 | 参数名 | 类型 | 必填 | 说明 | 213 | ------ | ------ | ---- | ------- | 214 | formId | string | 是 | 卡片标识 | 215 216**返回值:** 217 218 | 类型 | 说明 | 219 | -------- | -------- | 220 | Promise<void> | 返回一个Promise,包含接口的结果 | 221 222**示例:** 223 224 ```js 225 var formId = "12400633174999288"; 226 formHost.requestForm(formId).then(() => { 227 console.log('formHost requestForm success'); 228 }).catch((error) => { 229 console.log('formHost requestForm, error:' + JSON.stringify(error)); 230 }); 231 ``` 232 233## castTempForm 234 235castTempForm(formId: string, callback: AsyncCallback<void>): void; 236 237将指定的临时卡片转换为普通卡片。 238 239**系统能力:** 240 241SystemCapability.Ability.Form 242 243**参数:** 244 245| 参数名 | 类型 | 必填 | 说明 | 246| ------ | ------ | ---- | ------- | 247| formId | string | 是 | 卡片标识 | 248| callback | AsyncCallback<void> | 是 | callback形式返回结果 | 249 250**示例:** 251 252 ```js 253 var formId = "12400633174999288"; 254 formHost.castTempForm(formId, (error, data) => { 255 if (error.code) { 256 console.log('formHost castTempForm, error:' + JSON.stringify(error)); 257 } 258 }); 259 ``` 260 261## castTempForm 262 263castTempForm(formId: string): Promise<void>; 264 265将指定的临时卡片转换为普通卡片。 266 267**系统能力:** 268 269SystemCapability.Ability.Form 270 271**参数:** 272 273 | 参数名 | 类型 | 必填 | 说明 | 274 | ------ | ------ | ---- | ------- | 275 | formId | string | 是 | 卡片标识 | 276 277**返回值:** 278 279 | 类型 | 说明 | 280 | -------- | -------- | 281 | Promise<void> | 返回一个Promise,包含接口的结果 | 282 283**示例:** 284 285 ```js 286 var formId = "12400633174999288"; 287 formHost.castTempForm(formId).then(() => { 288 console.log('formHost castTempForm success'); 289 }).catch((error) => { 290 console.log('formHost castTempForm, error:' + JSON.stringify(error)); 291 }); 292 ``` 293 294## notifyVisibleForms 295 296notifyVisibleForms(formIds: Array<string>, callback: AsyncCallback<void>): void; 297 298向卡片框架发送通知以使指定的卡片可见。该方法调用成功后,会调用onVisibilityChange通知卡片提供方。 299 300**系统能力:** 301 302SystemCapability.Ability.Form 303 304**参数:** 305 306| 参数名 | 类型 | 必填 | 说明 | 307| ------ | ------ | ---- | ------- | 308| formIds | Array<string> | 是 | 卡片标识列表 | 309| callback | AsyncCallback<void> | 是 | callback形式返回结果 | 310 311**示例:** 312 313 ```js 314 var formId = "12400633174999288"; 315 formHost.notifyVisibleForms(formId, (error, data) => { 316 if (error.code) { 317 console.log('formHost notifyVisibleForms, error:' + JSON.stringify(error)); 318 } 319 }); 320 ``` 321 322## notifyVisibleForms 323 324notifyVisibleForms(formIds: Array<string>): Promise<void>; 325 326向卡片框架发送通知以使指定的卡片可见。该方法调用成功后,会调用onVisibilityChange通知卡片提供方。 327 328**系统能力:** 329 330SystemCapability.Ability.Form 331 332**参数:** 333 334| 参数名 | 类型 | 必填 | 说明 | 335| ------ | ------ | ---- | ------- | 336| formIds | Array<string> | 是 | 卡片标识列表 | 337 338**返回值:** 339 340 | 类型 | 说明 | 341 | -------- | -------- | 342 | Promise<void> | 返回一个Promise,包含接口的结果 | 343 344**示例:** 345 346 ```js 347 var formId = "12400633174999288"; 348 formHost.notifyVisibleForms(formId).then(() => { 349 console.log('formHost notifyVisibleForms success'); 350 }).catch((error) => { 351 console.log('formHost notifyVisibleForms, error:' + JSON.stringify(error)); 352 }); 353 ``` 354 355## notifyInvisibleForms 356 357notifyInvisibleForms(formIds: Array<string>, callback: AsyncCallback<void>): void; 358 359向卡片框架发送通知以使指定的卡片不可见。该方法调用成功后,会调用onVisibilityChange通知卡片提供方。 360 361**系统能力:** 362 363SystemCapability.Ability.Form 364 365**参数:** 366 367| 参数名 | 类型 | 必填 | 说明 | 368| ------ | ------ | ---- | ------- | 369| formIds | Array<string> | 是 | 卡片标识列表 | 370| callback | AsyncCallback<void> | 是 | callback形式返回结果 | 371 372**示例:** 373 374 ```js 375 var formId = "12400633174999288"; 376 formHost.notifyInvisibleForms(formId, (error, data) => { 377 if (error.code) { 378 console.log('formHost notifyInvisibleForms, error:' + JSON.stringify(error)); 379 } 380 }); 381 ``` 382 383## notifyInvisibleForms 384 385notifyInvisibleForms(formIds: Array<string>): Promise<void>; 386 387向卡片框架发送通知以使指定的卡片不可见。该方法调用成功后,会调用onVisibilityChange通知卡片提供方。 388 389**系统能力:** 390 391SystemCapability.Ability.Form 392 393**参数:** 394 395| 参数名 | 类型 | 必填 | 说明 | 396| ------ | ------ | ---- | ------- | 397| formIds | Array<string> | 是 | 卡片标识列表 | 398 399**返回值:** 400 401 | 类型 | 说明 | 402 | -------- | -------- | 403 | Promise<void> | 返回一个Promise,包含接口的结果 | 404 405**示例:** 406 407 ```js 408 var formId = "12400633174999288"; 409 formHost.notifyInvisibleForms(formId).then(() => { 410 console.log('formHost notifyInvisibleForms success'); 411 }).catch((error) => { 412 console.log('formHost notifyInvisibleForms, error:' + JSON.stringify(error)); 413 }); 414 ``` 415 416## enableFormsUpdate 417 418enableFormsUpdate(formIds: Array<string>, callback: AsyncCallback<void>): void; 419 420向卡片框架发送通知以使指定的卡片可以更新。该方法调用成功后,卡片刷新状态设置为使能,卡片可以接收来自卡片提供方的更新。 421 422**系统能力:** 423 424SystemCapability.Ability.Form 425 426**参数:** 427 428| 参数名 | 类型 | 必填 | 说明 | 429| ------ | ------ | ---- | ------- | 430| formIds | Array<string> | 是 | 卡片标识列表 | 431| callback | AsyncCallback<void> | 是 | callback形式返回结果 | 432 433**示例:** 434 435 ```js 436 var formId = "12400633174999288"; 437 formHost.enableFormsUpdate(formId, (error, data) => { 438 if (error.code) { 439 console.log('formHost enableFormsUpdate, error:' + JSON.stringify(error)); 440 } 441 }); 442 ``` 443 444## enableFormsUpdate 445 446enableFormsUpdate(formIds: Array<string>): Promise<void>; 447 448向卡片框架发送通知以使指定的卡片可以更新。该方法调用成功后,卡片刷新状态设置为使能,卡片可以接收来自卡片提供方的更新。 449 450**系统能力:** 451 452SystemCapability.Ability.Form 453 454**参数:** 455 456| 参数名 | 类型 | 必填 | 说明 | 457| ------ | ------ | ---- | ------- | 458| formIds | Array<string> | 是 | 卡片标识列表 | 459 460**返回值:** 461 462 | 类型 | 说明 | 463 | -------- | -------- | 464 | Promise<void> | 返回一个Promise,包含接口的结果 | 465 466**示例:** 467 468 ```js 469 var formId = "12400633174999288"; 470 formHost.enableFormsUpdate(formId).then(() => { 471 console.log('formHost enableFormsUpdate success'); 472 }).catch((error) => { 473 console.log('formHost enableFormsUpdate, error:' + JSON.stringify(error)); 474 }); 475 ``` 476 477## disableFormsUpdate 478 479disableFormsUpdate(formIds: Array<string>, callback: AsyncCallback<void>): void; 480 481向卡片框架发送通知以使指定的卡片不可以更新。该方法调用成功后,卡片刷新状态设置为去使能,卡片不可以接收来自卡片提供方的更新。 482 483**系统能力:** 484 485SystemCapability.Ability.Form 486 487**参数:** 488 489| 参数名 | 类型 | 必填 | 说明 | 490| ------ | ------ | ---- | ------- | 491| formIds | Array<string> | 是 | 卡片标识列表 | 492| callback | AsyncCallback<void> | 是 | callback形式返回结果 | 493 494**示例:** 495 496 ```js 497 var formId = "12400633174999288"; 498 formHost.disableFormsUpdate(formId, (error, data) => { 499 if (error.code) { 500 console.log('formHost disableFormsUpdate, error:' + JSON.stringify(error)); 501 } 502 }); 503 ``` 504 505## disableFormsUpdate 506 507disableFormsUpdate(formIds: Array<string>): Promise<void>; 508 509向卡片框架发送通知以使指定的卡片不可以更新。该方法调用成功后,卡片刷新状态设置为去使能,卡片不可以接收来自卡片提供方的更新。 510 511**系统能力:** 512 513SystemCapability.Ability.Form 514 515**参数:** 516 517| 参数名 | 类型 | 必填 | 说明 | 518| ------ | ------ | ---- | ------- | 519| formIds | Array<string> | 是 | 卡片标识列表 | 520 521**返回值:** 522 523 | 类型 | 说明 | 524 | -------- | -------- | 525 | Promise<void> | 返回一个Promise,包含接口的结果 | 526 527**示例:** 528 529 ```js 530 var formId = "12400633174999288"; 531 formHost.disableFormsUpdate(formId).then(() => { 532 console.log('formHost disableFormsUpdate success'); 533 }).catch((error) => { 534 console.log('formHost disableFormsUpdate, error:' + JSON.stringify(error)); 535 }); 536 ``` 537 538## isSystemReady 539 540isSystemReady(callback: AsyncCallback<void>): void; 541 542检查系统是否准备好。 543 544**系统能力:** 545 546SystemCapability.Ability.Form 547 548**参数:** 549 550| 参数名 | 类型 | 必填 | 说明 | 551| ------ | ------ | ---- | ------- | 552| callback | AsyncCallback<void> | 是 | callback形式返回结果 | 553 554**示例:** 555 556 ```js 557 var formId = "12400633174999288"; 558 formHost.isSystemReady((error, data) => { 559 if (error.code) { 560 console.log('formHost isSystemReady, error:' + JSON.stringify(error)); 561 } 562 }); 563 ``` 564 565## isSystemReady 566 567isSystemReady(): Promise<void>; 568 569检查系统是否准备好。 570 571**系统能力:** 572 573SystemCapability.Ability.Form 574 575**返回值:** 576 577 | 类型 | 说明 | 578 | -------- | -------- | 579 | Promise<void> | 返回一个Promise,包含接口的结果 | 580 581**示例:** 582 583 ```js 584 var formId = "12400633174999288"; 585 formHost.isSystemReady().then(() => { 586 console.log('formHost isSystemReady success'); 587 }).catch((error) => { 588 console.log('formHost isSystemReady, error:' + JSON.stringify(error)); 589 }); 590 ``` 591 592## getAllFormsInfo 593 594getAllFormsInfo(callback: AsyncCallback<Array<formInfo.FormInfo>>): void; 595 596获取设备上所有应用提供的卡片信息。 597 598**系统能力:** 599 600SystemCapability.Ability.Form 601 602**参数:** 603 604 | 参数名 | 类型 | 必填 | 说明 | 605 | ------ | ------ | ---- | ------- | 606 | callback | AsyncCallback<Array<[FormInfo](./js-apis-formInfo.md#forminfo-1)>> | 是 | callback形式返回查询到的卡片信息 | 607 608**示例:** 609 610 ```js 611 formHost.getAllFormsInfo((error, data) => { 612 if (error.code) { 613 console.log('formHost getAllFormsInfo, error:' + JSON.stringify(error)); 614 } else { 615 console.log('formHost getAllFormsInfo, data:' + JSON.stringify(data)); 616 } 617 }); 618 ``` 619 620## getAllFormsInfo 621 622getAllFormsInfo(): Promise<Array<formInfo.FormInfo>>; 623 624获取设备上所有应用提供的卡片信息。 625 626**系统能力:** 627 628SystemCapability.Ability.Form 629 630**返回值:** 631 632| 类型 | 说明 | 633| :------------ | :---------------------------------- | 634| Promise<Array<[FormInfo](./js-apis-formInfo.md#forminfo-1)>> | Promise实例,用于获取异步返回查询到的卡片信息 | 635 636**示例:** 637 638 ```js 639 formHost.getAllFormsInfo().then((data) => { 640 console.log('formHost getAllFormsInfo data:' + JSON.stringify(data)); 641 }).catch((error) => { 642 console.log('formHost getAllFormsInfo, error:' + JSON.stringify(error)); 643 }); 644 ``` 645 646## getFormsInfo 647 648getFormsInfo(bundleName: string, callback: AsyncCallback<Array<formInfo.FormInfo>>): void; 649 650获取设备上指定应用程序提供的卡片信息。 651 652**系统能力:** 653 654SystemCapability.Ability.Form 655 656**参数:** 657 658 | 参数名 | 类型 | 必填 | 说明 | 659 | ------ | ------ | ---- | ------- | 660 | bundleName | string | 是 | 要查询的应用程序包名称 | 661 | callback | AsyncCallback<Array<[FormInfo](./js-apis-formInfo.md#forminfo-1)>> | 是 | callback形式返回查询到的卡片信息 | 662 663**示例:** 664 665 ```js 666 formHost.getFormsInfo("com.example.ohos.formjsdemo", (error, data) => { 667 if (error.code) { 668 console.log('formHost getFormsInfo, error:' + JSON.stringify(error)); 669 } else { 670 console.log('formHost getFormsInfo, data:' + JSON.stringify(data)); 671 } 672 }); 673 ``` 674 675## getFormsInfo 676 677getFormsInfo(bundleName: string, moduleName: string, callback: AsyncCallback<Array<formInfo.FormInfo>>): void; 678 679获取设备上指定应用程序提供的卡片信息。 680 681**系统能力:** 682 683SystemCapability.Ability.Form 684 685**参数:** 686 687 | 参数名 | 类型 | 必填 | 说明 | 688 | ------ | ------ | ---- | ------- | 689 | bundleName | string | 是 | 要查询的应用程序包名称 | 690 | moduleName | string | 是 | 要查询的模块名称 | 691 | callback | AsyncCallback<Array<[FormInfo](./js-apis-formInfo.md#forminfo-1)>> | 是 | callback形式返回查询到的卡片信息 | 692 693**示例:** 694 695 ```js 696 formHost.getFormsInfo("com.example.ohos.formjsdemo", "entry", (error, data) => { 697 if (error.code) { 698 console.log('formHost getFormsInfo, error:' + JSON.stringify(error)); 699 } else { 700 console.log('formHost getFormsInfo, data:' + JSON.stringify(data)); 701 } 702 }); 703 ``` 704 705## getFormsInfo 706 707getFormsInfo(bundleName: string, moduleName?: string): Promise<Array<formInfo.FormInfo>>; 708 709获取设备上指定应用程序提供的卡片信息。 710 711**系统能力:** 712 713SystemCapability.Ability.Form 714 715**参数:** 716 717 | 参数名 | 类型 | 必填 | 说明 | 718 | ------ | ------ | ---- | ------- | 719 | bundleName | string | 是 | 要查询的应用程序包名称 | 720 | moduleName | string | 否 | 要查询的模块名称 | 721 722**返回值:** 723 724| 类型 | 说明 | 725| :------------ | :---------------------------------- | 726| Promise<Array<[FormInfo](./js-apis-formInfo.md#forminfo-1)>> | Promise实例,用于获取异步返回查询到的卡片信息 | 727 728**示例:** 729 730 ```js 731 formHost.getFormsInfo("com.example.ohos.formjsdemo", "entry").then((data) => { 732 console.log('formHost getFormsInfo, data:' + JSON.stringify(data)); 733 }).catch((error) => { 734 console.log('formHost getFormsInfo, error:' + JSON.stringify(error)); 735 }); 736 ``` 737 738## deleteInvalidForms 739 740deleteInvalidForms(formIds: Array<string>, callback: AsyncCallback<number>): void; 741 742根据列表删除应用程序的无效卡片。 743 744**系统能力:** 745 746SystemCapability.Ability.Form 747 748**参数:** 749 750| 参数名 | 类型 | 必填 | 说明 | 751| ------ | ------ | ---- | ------- | 752| formIds | Array<string> | 是 | 有效卡片标识列表 | 753| callback | AsyncCallback<number> | 是 | callback形式返回删除的卡片个数 | 754 755**示例:** 756 757 ```js 758 var formIds = new Array("12400633174999288", "12400633174999289"); 759 formHost.deleteInvalidForms(formIds, (error, data) => { 760 if (error.code) { 761 console.log('formHost deleteInvalidForms, error:' + JSON.stringify(error)); 762 } else { 763 console.log('formHost deleteInvalidForms, data:' + JSON.stringify(data)); 764 } 765 }); 766 ``` 767 768## deleteInvalidForms 769 770deleteInvalidForms(formIds: Array<string>): Promise<number>; 771 772根据列表删除应用程序的无效卡片。 773 774**系统能力:** 775 776SystemCapability.Ability.Form 777 778**参数:** 779 780| 参数名 | 类型 | 必填 | 说明 | 781| ------ | ------ | ---- | ------- | 782| formIds | Array<string> | 是 | 有效卡片标识列表 | 783 784**返回值:** 785 786| 类型 | 说明 | 787| :------------ | :---------------------------------- | 788| Promise<number> | Promise实例,用于获取异步返回删除的卡片个数 | 789 790**示例:** 791 792 ```js 793 var formIds = new Array("12400633174999288", "12400633174999289"); 794 formHost.deleteInvalidForms(formIds).then((data) => { 795 console.log('formHost deleteInvalidForms, data:' + JSON.stringify(data)); 796 }).catch((error) => { 797 console.log('formHost deleteInvalidForms, error:' + JSON.stringify(error)); 798 }); 799 ``` 800 801## acquireFormState 802 803acquireFormState(want: Want, callback: AsyncCallback<formInfo.FormStateInfo>): void; 804 805获取卡片状态 806 807**系统能力:** 808 809SystemCapability.Ability.Form 810 811**参数:** 812 813| 参数名 | 类型 | 必填 | 说明 | 814| ------ | ------ | ---- | ------- | 815| want | [Want](js-apis-featureAbility.md#want) | 是 | 查询卡片状态时携带的want信息 | 816| callback | AsyncCallback<[FormStateInfo](js-apis-formInfo.md#formstateinfo)> | 是 | callback形式返回卡片状态 | 817 818**示例:** 819 820 ```js 821 var want = { 822 "deviceId": "", 823 "bundleName": "ohos.samples.FormApplication", 824 "abilityName": "FormAbility", 825 "parameters": { 826 "ohos.extra.param.key.module_name": "entry", 827 "ohos.extra.param.key.form_name": "widget", 828 "ohos.extra.param.key.form_dimension": 2 829 } 830 }; 831 formHost.acquireFormState(want, (error, data) => { 832 if (error.code) { 833 console.log('formHost acquireFormState, error:' + JSON.stringify(error)); 834 } else { 835 console.log('formHost acquireFormState, data:' + JSON.stringify(data)); 836 } 837 }); 838 ``` 839 840## acquireFormState 841 842acquireFormState(want: Want): Promise<formInfo.FormStateInfo>; 843 844获取卡片状态。 845 846**参数:** 847 848| 参数名 | 类型 | 必填 | 说明 | 849| ------ | ------ | ---- | ------- | 850| want | [Want](js-apis-featureAbility.md#want) | 是 | 查询卡片状态时携带的want信息 | 851 852**返回值:** 853 854| 类型 | 说明 | 855| :------------ | :---------------------------------- | 856| Promise<[FormStateInfo](js-apis-formInfo.md#formstateinfo)> | Promise实例,用于返回卡片状态 | 857 858**系统能力:** 859 860SystemCapability.Ability.Form 861 862**示例:** 863 864 ```js 865 var want = { 866 "deviceId": "", 867 "bundleName": "ohos.samples.FormApplication", 868 "abilityName": "FormAbility", 869 "parameters": { 870 "ohos.extra.param.key.module_name": "entry", 871 "ohos.extra.param.key.form_name": "widget", 872 "ohos.extra.param.key.form_dimension": 2 873 } 874 }; 875 formHost.acquireFormState(want).then((data) => { 876 console.log('formHost acquireFormState, data:' + JSON.stringify(data)); 877 }).catch((error) => { 878 console.log('formHost acquireFormState, error:' + JSON.stringify(error)); 879 }); 880 ``` 881 882## on("formUninstall") 883 884on(type: "formUninstall", callback: Callback<string>): void; 885 886订阅卡片卸载事件。 887 888**系统能力:** 889 890SystemCapability.Ability.Form 891 892**参数:** 893 894| 参数名 | 类型 | 必填 | 说明 | 895| ------ | ------ | ---- | ------- | 896| type | string | 是 | 填写"formUninstall",表示卡片卸载事件 | 897| callback | Callback<string> | 是 | 需要注册的事件回调方法 | 898 899**示例:** 900 901 ```js 902 let callback = function(formId) { 903 console.log('formHost on formUninstall, formId:' + formId); 904 } 905 formHost.on("formUninstall", callback); 906 ``` 907 908## off("formUninstall") 909 910off(type: "formUninstall", callback?: Callback<string>): void; 911 912取消订阅卡片卸载事件。 913 914**系统能力:** 915 916SystemCapability.Ability.Form 917 918**参数:** 919 920| 参数名 | 类型 | 必填 | 说明 | 921| ------ | ------ | ---- | ------- | 922| type | string | 是 | 填写"formUninstall",表示卡片卸载事件 | 923| callback | Callback<string> | 否 | 需要注销的事件回调方法。缺省时,表示注销所有已注册事件回调 | 924 925**示例:** 926 927 ```js 928 let callback = function(formId) { 929 console.log('formHost on formUninstall, formId:' + formId); 930 } 931 formHost.off("formUninstall", callback); 932 ``` 933 934## notifyFormsVisible 935 936notifyFormsVisible(formIds: Array<string>, isVisible: boolean, callback: AsyncCallback<void>): void; 937 938通知卡片是否可见。 939 940**系统能力:** 941 942SystemCapability.Ability.Form 943 944**参数:** 945 946| 参数名 | 类型 | 必填 | 说明 | 947| ------ | ------ | ---- | ------- | 948| formIds | Array<string> | 是 | 卡片标识列表 | 949| isVisible | boolean | 是 | 是否可见 | 950| callback | AsyncCallback<void> | 是 | callback形式返回结果 | 951 952**示例:** 953 954 ```js 955 var formIds = new Array("12400633174999288", "12400633174999289"); 956 formHost.notifyFormsVisible(formIds, true, (error, data) => { 957 if (error.code) { 958 console.log('formHost notifyFormsVisible, error:' + JSON.stringify(error)); 959 } 960 }); 961 ``` 962 963## notifyFormsVisible 964 965notifyFormsVisible(formIds: Array<string>, isVisible: boolean): Promise<void>; 966 967通知卡片是否可见。 968 969**系统能力:** 970 971SystemCapability.Ability.Form 972 973**参数:** 974 975 | 参数名 | 类型 | 必填 | 说明 | 976 | ------ | ------ | ---- | ------- | 977 | formIds | Array<string> | 是 | 卡片标识列表 | 978 | isVisible | boolean | 是 | 是否可见 | 979 980**返回值:** 981 982 | 类型 | 说明 | 983 | -------- | -------- | 984 | Promise<void> | 返回一个Promise,包含接口的结果 | 985 986**示例:** 987 988 ```js 989 var formIds = new Array("12400633174999288", "12400633174999289"); 990 formHost.notifyFormsVisible(formIds, true).then(() => { 991 console.log('formHost notifyFormsVisible success'); 992 }).catch((error) => { 993 console.log('formHost notifyFormsVisible, error:' + JSON.stringify(error)); 994 }); 995 ``` 996 997## notifyFormsEnableUpdate 998 999notifyFormsEnableUpdate(formIds: Array<string>, isEnableUpdate: boolean, callback: AsyncCallback<void>): void; 1000 1001通知卡片是否启用更新状态。 1002 1003**系统能力:** 1004 1005SystemCapability.Ability.Form 1006 1007**参数:** 1008 1009| 参数名 | 类型 | 必填 | 说明 | 1010| ------ | ------ | ---- | ------- | 1011| formIds | Array<string> | 是 | 卡片标识列表 | 1012| isEnableUpdate | boolean | 是 | 是否使能更新 | 1013| callback | AsyncCallback<void> | 是 | callback形式返回结果 | 1014 1015**示例:** 1016 1017 ```js 1018 var formIds = new Array("12400633174999288", "12400633174999289"); 1019 formHost.notifyFormsEnableUpdate(formIds, true, (error, data) => { 1020 if (error.code) { 1021 console.log('formHost notifyFormsEnableUpdate, error:' + JSON.stringify(error)); 1022 } 1023 }); 1024 ``` 1025 1026## notifyFormsEnableUpdate 1027 1028notifyFormsEnableUpdate(formIds: Array<string>, isEnableUpdate: boolean): Promise<void>; 1029 1030通知卡片是否启用更新状态。 1031 1032**系统能力:** 1033 1034SystemCapability.Ability.Form 1035 1036**参数:** 1037 1038 | 参数名 | 类型 | 必填 | 说明 | 1039 | ------ | ------ | ---- | ------- | 1040 | formIds | Array<string> | 是 | 卡片标识列表 | 1041 | isEnableUpdate | boolean | 是 | 是否使能更新 | 1042 1043**返回值:** 1044 1045 | 类型 | 说明 | 1046 | -------- | -------- | 1047 | Promise<void> | 返回一个Promise,包含接口的结果 | 1048 1049**示例:** 1050 1051 ```js 1052 var formIds = new Array("12400633174999288", "12400633174999289"); 1053 formHost.notifyFormsEnableUpdate(formIds, true).then(() => { 1054 console.log('formHost notifyFormsEnableUpdate success'); 1055 }).catch((error) => { 1056 console.log('formHost notifyFormsEnableUpdate, error:' + JSON.stringify(error)); 1057 }); 1058 ```