1e41f4b71Sopenharmony_ci# @ohos.app.form.formHost (formHost)(系统接口) 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ciformHost模块提供了卡片使用方相关接口的能力,包括对使用方同一用户下安装的卡片进行删除、释放、请求更新、获取卡片信息、状态等操作。 4e41f4b71Sopenharmony_ci 5e41f4b71Sopenharmony_ci> **说明:** 6e41f4b71Sopenharmony_ci> 7e41f4b71Sopenharmony_ci> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 8e41f4b71Sopenharmony_ci> 本模块接口均为系统接口。 9e41f4b71Sopenharmony_ci 10e41f4b71Sopenharmony_ci## 导入模块 11e41f4b71Sopenharmony_ci 12e41f4b71Sopenharmony_ci```ts 13e41f4b71Sopenharmony_ciimport { formHost } from '@kit.FormKit'; 14e41f4b71Sopenharmony_ci``` 15e41f4b71Sopenharmony_ci 16e41f4b71Sopenharmony_ci## deleteForm 17e41f4b71Sopenharmony_ci 18e41f4b71Sopenharmony_cideleteForm(formId: string, callback: AsyncCallback<void>): void 19e41f4b71Sopenharmony_ci 20e41f4b71Sopenharmony_ci删除指定的卡片。调用此方法后,应用程序将无法使用该卡片,卡片管理器服务不再保留有关该卡片的信息。使用callback异步回调。 21e41f4b71Sopenharmony_ci 22e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.REQUIRE_FORM 23e41f4b71Sopenharmony_ci 24e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Ability.Form 25e41f4b71Sopenharmony_ci 26e41f4b71Sopenharmony_ci**参数:** 27e41f4b71Sopenharmony_ci 28e41f4b71Sopenharmony_ci| 参数名 | 类型 | 必填 | 说明 | 29e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ------- | 30e41f4b71Sopenharmony_ci| formId | string | 是 | 卡片标识。 | 31e41f4b71Sopenharmony_ci| callback | AsyncCallback<void> | 是 | 回调函数。当删除指定的卡片成功,error为undefined,否则为错误对象。 | 32e41f4b71Sopenharmony_ci 33e41f4b71Sopenharmony_ci**错误码:** 34e41f4b71Sopenharmony_ci 35e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 | 36e41f4b71Sopenharmony_ci| -------- | -------- | 37e41f4b71Sopenharmony_ci| 201 | Permissions denied. | 38e41f4b71Sopenharmony_ci| 202 | The application is not a system application. | 39e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. | 40e41f4b71Sopenharmony_ci| 16500050 | IPC connection error. | 41e41f4b71Sopenharmony_ci| 16500060 | Service connection error. | 42e41f4b71Sopenharmony_ci| 16501000 | An internal functional error occurred. | 43e41f4b71Sopenharmony_ci| 16501001 | The ID of the form to be operated does not exist. | 44e41f4b71Sopenharmony_ci| 16501003 | The form cannot be operated by the current application. | 45e41f4b71Sopenharmony_ci 46e41f4b71Sopenharmony_ci以上错误码的详细介绍请参见[卡片错误码](errorcode-form.md)。 47e41f4b71Sopenharmony_ci 48e41f4b71Sopenharmony_ci**示例:** 49e41f4b71Sopenharmony_ci 50e41f4b71Sopenharmony_ci```ts 51e41f4b71Sopenharmony_ciimport { formHost } from '@kit.FormKit'; 52e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 53e41f4b71Sopenharmony_ci 54e41f4b71Sopenharmony_citry { 55e41f4b71Sopenharmony_ci let formId: string = '12400633174999288'; 56e41f4b71Sopenharmony_ci formHost.deleteForm(formId, (error: BusinessError) => { 57e41f4b71Sopenharmony_ci if (error) { 58e41f4b71Sopenharmony_ci console.error(`error, code: ${error.code}, message: ${error.message}`); 59e41f4b71Sopenharmony_ci } else { 60e41f4b71Sopenharmony_ci console.log('formHost deleteForm success'); 61e41f4b71Sopenharmony_ci } 62e41f4b71Sopenharmony_ci }); 63e41f4b71Sopenharmony_ci} catch (error) { 64e41f4b71Sopenharmony_ci console.error(`catch error, code: ${(error as BusinessError).code}, message: ${(error as BusinessError).message}`); 65e41f4b71Sopenharmony_ci} 66e41f4b71Sopenharmony_ci``` 67e41f4b71Sopenharmony_ci 68e41f4b71Sopenharmony_ci## deleteForm 69e41f4b71Sopenharmony_ci 70e41f4b71Sopenharmony_cideleteForm(formId: string): Promise<void> 71e41f4b71Sopenharmony_ci 72e41f4b71Sopenharmony_ci删除指定的卡片。调用此方法后,应用程序将无法使用该卡片,卡片管理器服务不再保留有关该卡片的信息。使用Promise异步回调。 73e41f4b71Sopenharmony_ci 74e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.REQUIRE_FORM 75e41f4b71Sopenharmony_ci 76e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Ability.Form 77e41f4b71Sopenharmony_ci 78e41f4b71Sopenharmony_ci**参数:** 79e41f4b71Sopenharmony_ci 80e41f4b71Sopenharmony_ci| 参数名 | 类型 | 必填 | 说明 | 81e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ------- | 82e41f4b71Sopenharmony_ci| formId | string | 是 | 卡片标识。 | 83e41f4b71Sopenharmony_ci 84e41f4b71Sopenharmony_ci**返回值:** 85e41f4b71Sopenharmony_ci 86e41f4b71Sopenharmony_ci| 类型 | 说明 | 87e41f4b71Sopenharmony_ci| -------- | -------- | 88e41f4b71Sopenharmony_ci| Promise<void> | 无返回结果的Promise对象。 | 89e41f4b71Sopenharmony_ci 90e41f4b71Sopenharmony_ci 91e41f4b71Sopenharmony_ci**错误码:** 92e41f4b71Sopenharmony_ci 93e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 | 94e41f4b71Sopenharmony_ci| -------- | -------- | 95e41f4b71Sopenharmony_ci| 201 | Permissions denied. | 96e41f4b71Sopenharmony_ci| 202 | The application is not a system application. | 97e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. | 98e41f4b71Sopenharmony_ci| 16500050 | IPC connection error. | 99e41f4b71Sopenharmony_ci| 16500060 | Service connection error. | 100e41f4b71Sopenharmony_ci| 16501000 | An internal functional error occurred. | 101e41f4b71Sopenharmony_ci| 16501001 | The ID of the form to be operated does not exist. | 102e41f4b71Sopenharmony_ci| 16501003 | The form cannot be operated by the current application. | 103e41f4b71Sopenharmony_ci 104e41f4b71Sopenharmony_ci以上错误码的详细介绍请参见[卡片错误码](errorcode-form.md)。 105e41f4b71Sopenharmony_ci 106e41f4b71Sopenharmony_ci**示例:** 107e41f4b71Sopenharmony_ci 108e41f4b71Sopenharmony_ci```ts 109e41f4b71Sopenharmony_ciimport { formHost } from '@kit.FormKit'; 110e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 111e41f4b71Sopenharmony_ci 112e41f4b71Sopenharmony_citry { 113e41f4b71Sopenharmony_ci let formId: string = '12400633174999288'; 114e41f4b71Sopenharmony_ci formHost.deleteForm(formId).then(() => { 115e41f4b71Sopenharmony_ci console.log('formHost deleteForm success'); 116e41f4b71Sopenharmony_ci }).catch((error: BusinessError) => { 117e41f4b71Sopenharmony_ci console.error(`formHost deleteForm, error: ${JSON.stringify(error)}`); 118e41f4b71Sopenharmony_ci }); 119e41f4b71Sopenharmony_ci} catch (error) { 120e41f4b71Sopenharmony_ci console.error(`catch error, code: ${(error as BusinessError).code}, message: ${(error as BusinessError).message}`); 121e41f4b71Sopenharmony_ci} 122e41f4b71Sopenharmony_ci``` 123e41f4b71Sopenharmony_ci 124e41f4b71Sopenharmony_ci## releaseForm 125e41f4b71Sopenharmony_ci 126e41f4b71Sopenharmony_cireleaseForm(formId: string, callback: AsyncCallback<void>): void 127e41f4b71Sopenharmony_ci 128e41f4b71Sopenharmony_ci释放指定的卡片。调用此方法后,应用程序将无法使用该卡片,但卡片管理器服务仍然保留有关该卡片的缓存信息和存储信息。使用callback异步回调。 129e41f4b71Sopenharmony_ci 130e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.REQUIRE_FORM 131e41f4b71Sopenharmony_ci 132e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Ability.Form 133e41f4b71Sopenharmony_ci 134e41f4b71Sopenharmony_ci**参数:** 135e41f4b71Sopenharmony_ci 136e41f4b71Sopenharmony_ci| 参数名 | 类型 | 必填 | 说明 | 137e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ------- | 138e41f4b71Sopenharmony_ci| formId | string | 是 | 卡片标识。 | 139e41f4b71Sopenharmony_ci| callback | AsyncCallback<void> | 是 | 回调函数。当释放指定的卡片成功,error为undefined;否则为错误对象。| 140e41f4b71Sopenharmony_ci 141e41f4b71Sopenharmony_ci**错误码:** 142e41f4b71Sopenharmony_ci 143e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 | 144e41f4b71Sopenharmony_ci| -------- | -------- | 145e41f4b71Sopenharmony_ci| 201 | Permissions denied. | 146e41f4b71Sopenharmony_ci| 202 | The application is not a system application. | 147e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. | 148e41f4b71Sopenharmony_ci| 16500050 | IPC connection error. | 149e41f4b71Sopenharmony_ci| 16500060 | Service connection error. | 150e41f4b71Sopenharmony_ci| 16501000 | An internal functional error occurred. | 151e41f4b71Sopenharmony_ci| 16501001 | The ID of the form to be operated does not exist. | 152e41f4b71Sopenharmony_ci| 16501003 | The form cannot be operated by the current application. | 153e41f4b71Sopenharmony_ci 154e41f4b71Sopenharmony_ci以上错误码的详细介绍请参见[卡片错误码](errorcode-form.md)。 155e41f4b71Sopenharmony_ci 156e41f4b71Sopenharmony_ci**示例:** 157e41f4b71Sopenharmony_ci 158e41f4b71Sopenharmony_ci```ts 159e41f4b71Sopenharmony_ciimport { formHost } from '@kit.FormKit'; 160e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 161e41f4b71Sopenharmony_ci 162e41f4b71Sopenharmony_citry { 163e41f4b71Sopenharmony_ci let formId: string = '12400633174999288'; 164e41f4b71Sopenharmony_ci formHost.releaseForm(formId, (error: BusinessError) => { 165e41f4b71Sopenharmony_ci if (error) { 166e41f4b71Sopenharmony_ci console.error(`error, code: ${error.code}, message: ${error.message}`); 167e41f4b71Sopenharmony_ci } 168e41f4b71Sopenharmony_ci }); 169e41f4b71Sopenharmony_ci} catch (error) { 170e41f4b71Sopenharmony_ci console.error(`catch error, code: ${(error as BusinessError).code}, message: ${(error as BusinessError).message}`); 171e41f4b71Sopenharmony_ci} 172e41f4b71Sopenharmony_ci``` 173e41f4b71Sopenharmony_ci 174e41f4b71Sopenharmony_ci## releaseForm 175e41f4b71Sopenharmony_ci 176e41f4b71Sopenharmony_cireleaseForm(formId: string, isReleaseCache: boolean, callback: AsyncCallback<void>): void 177e41f4b71Sopenharmony_ci 178e41f4b71Sopenharmony_ci释放指定的卡片。调用此方法后,应用程序将无法使用该卡片,卡片管理器服务保留有关该卡片的存储信息,可以选择是否保留缓存信息。使用callback异步回调。 179e41f4b71Sopenharmony_ci 180e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.REQUIRE_FORM 181e41f4b71Sopenharmony_ci 182e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Ability.Form 183e41f4b71Sopenharmony_ci 184e41f4b71Sopenharmony_ci**参数:** 185e41f4b71Sopenharmony_ci 186e41f4b71Sopenharmony_ci| 参数名 | 类型 | 必填 | 说明 | 187e41f4b71Sopenharmony_ci| -------------- | ------ | ---- | ----------- | 188e41f4b71Sopenharmony_ci| formId | string | 是 | 卡片标识。 | 189e41f4b71Sopenharmony_ci| isReleaseCache | boolean | 是 | 是否释放缓存。 | 190e41f4b71Sopenharmony_ci| callback | AsyncCallback<void> | 是 | 回调函数。当释放指定的卡片成功,error为undefined;否则为错误对象。 | 191e41f4b71Sopenharmony_ci 192e41f4b71Sopenharmony_ci**错误码:** 193e41f4b71Sopenharmony_ci 194e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 | 195e41f4b71Sopenharmony_ci| -------- | -------- | 196e41f4b71Sopenharmony_ci| 201 | Permissions denied. | 197e41f4b71Sopenharmony_ci| 202 | The application is not a system application. | 198e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. | 199e41f4b71Sopenharmony_ci| 16500050 | IPC connection error. | 200e41f4b71Sopenharmony_ci| 16500060 | Service connection error. | 201e41f4b71Sopenharmony_ci| 16501000 | An internal functional error occurred. | 202e41f4b71Sopenharmony_ci| 16501001 | The ID of the form to be operated does not exist. | 203e41f4b71Sopenharmony_ci| 16501003 | The form cannot be operated by the current application. | 204e41f4b71Sopenharmony_ci 205e41f4b71Sopenharmony_ci以上错误码的详细介绍请参见[卡片错误码](errorcode-form.md)。 206e41f4b71Sopenharmony_ci 207e41f4b71Sopenharmony_ci**示例:** 208e41f4b71Sopenharmony_ci 209e41f4b71Sopenharmony_ci```ts 210e41f4b71Sopenharmony_ciimport { formHost } from '@kit.FormKit'; 211e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 212e41f4b71Sopenharmony_ci 213e41f4b71Sopenharmony_citry { 214e41f4b71Sopenharmony_ci let formId: string = '12400633174999288'; 215e41f4b71Sopenharmony_ci formHost.releaseForm(formId, true, (error: BusinessError) => { 216e41f4b71Sopenharmony_ci if (error) { 217e41f4b71Sopenharmony_ci console.error(`error, code: ${error.code}, message: ${error.message}`); 218e41f4b71Sopenharmony_ci } 219e41f4b71Sopenharmony_ci }); 220e41f4b71Sopenharmony_ci} catch(error) { 221e41f4b71Sopenharmony_ci console.error(`catch error, code: ${(error as BusinessError).code}, message: ${(error as BusinessError).message}`); 222e41f4b71Sopenharmony_ci} 223e41f4b71Sopenharmony_ci``` 224e41f4b71Sopenharmony_ci 225e41f4b71Sopenharmony_ci## releaseForm 226e41f4b71Sopenharmony_ci 227e41f4b71Sopenharmony_cireleaseForm(formId: string, isReleaseCache?: boolean): Promise<void> 228e41f4b71Sopenharmony_ci 229e41f4b71Sopenharmony_ci释放指定的卡片。调用此方法后,应用程序将无法使用该卡片,卡片管理器服务保留有关该卡片的存储信息,可以选择是否保留缓存信息。使用Promise异步回调。 230e41f4b71Sopenharmony_ci 231e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.REQUIRE_FORM 232e41f4b71Sopenharmony_ci 233e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Ability.Form 234e41f4b71Sopenharmony_ci 235e41f4b71Sopenharmony_ci**参数:** 236e41f4b71Sopenharmony_ci 237e41f4b71Sopenharmony_ci| 参数名 | 类型 | 必填 | 说明 | 238e41f4b71Sopenharmony_ci| -------------- | ------ | ---- | ----------- | 239e41f4b71Sopenharmony_ci| formId | string | 是 | 卡片标识。 | 240e41f4b71Sopenharmony_ci| isReleaseCache | boolean | 否 | 是否释放缓存,默认为false。 | 241e41f4b71Sopenharmony_ci 242e41f4b71Sopenharmony_ci**返回值:** 243e41f4b71Sopenharmony_ci 244e41f4b71Sopenharmony_ci| 类型 | 说明 | 245e41f4b71Sopenharmony_ci| -------- | -------- | 246e41f4b71Sopenharmony_ci| Promise<void> | 无返回结果的Promise对象。 | 247e41f4b71Sopenharmony_ci 248e41f4b71Sopenharmony_ci**错误码:** 249e41f4b71Sopenharmony_ci 250e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 | 251e41f4b71Sopenharmony_ci| -------- | -------- | 252e41f4b71Sopenharmony_ci| 201 | Permissions denied. | 253e41f4b71Sopenharmony_ci| 202 | The application is not a system application. | 254e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. | 255e41f4b71Sopenharmony_ci| 16500050 | IPC connection error. | 256e41f4b71Sopenharmony_ci| 16500060 | Service connection error. | 257e41f4b71Sopenharmony_ci| 16501000 | An internal functional error occurred. | 258e41f4b71Sopenharmony_ci| 16501001 | The ID of the form to be operated does not exist. | 259e41f4b71Sopenharmony_ci| 16501003 | The form cannot be operated by the current application. | 260e41f4b71Sopenharmony_ci 261e41f4b71Sopenharmony_ci以上错误码的详细介绍请参见[卡片错误码](errorcode-form.md)。 262e41f4b71Sopenharmony_ci 263e41f4b71Sopenharmony_ci**示例:** 264e41f4b71Sopenharmony_ci 265e41f4b71Sopenharmony_ci```ts 266e41f4b71Sopenharmony_ciimport { formHost } from '@kit.FormKit'; 267e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 268e41f4b71Sopenharmony_ci 269e41f4b71Sopenharmony_citry { 270e41f4b71Sopenharmony_ci let formId: string = '12400633174999288'; 271e41f4b71Sopenharmony_ci formHost.releaseForm(formId, true).then(() => { 272e41f4b71Sopenharmony_ci console.log('formHost releaseForm success'); 273e41f4b71Sopenharmony_ci }).catch((error: BusinessError) => { 274e41f4b71Sopenharmony_ci console.error(`error, code: ${error.code}, message: ${error.message}`); 275e41f4b71Sopenharmony_ci }); 276e41f4b71Sopenharmony_ci} catch(error) { 277e41f4b71Sopenharmony_ci console.error(`catch error, code: ${(error as BusinessError).code}, message: ${(error as BusinessError).message}`); 278e41f4b71Sopenharmony_ci} 279e41f4b71Sopenharmony_ci``` 280e41f4b71Sopenharmony_ci 281e41f4b71Sopenharmony_ci## requestForm 282e41f4b71Sopenharmony_ci 283e41f4b71Sopenharmony_cirequestForm(formId: string, callback: AsyncCallback<void>): void 284e41f4b71Sopenharmony_ci 285e41f4b71Sopenharmony_ci请求卡片更新。使用callback异步回调。 286e41f4b71Sopenharmony_ci 287e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.REQUIRE_FORM 288e41f4b71Sopenharmony_ci 289e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Ability.Form 290e41f4b71Sopenharmony_ci 291e41f4b71Sopenharmony_ci**参数:** 292e41f4b71Sopenharmony_ci 293e41f4b71Sopenharmony_ci| 参数名 | 类型 | 必填 | 说明 | 294e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ------- | 295e41f4b71Sopenharmony_ci| formId | string | 是 | 卡片标识。 | 296e41f4b71Sopenharmony_ci| callback | AsyncCallback<void> | 是 | 回调函数。当请求卡片更新成功,error为undefined;否则为错误对象。 | 297e41f4b71Sopenharmony_ci 298e41f4b71Sopenharmony_ci**错误码:** 299e41f4b71Sopenharmony_ci 300e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 | 301e41f4b71Sopenharmony_ci| -------- | -------- | 302e41f4b71Sopenharmony_ci| 201 | Permissions denied. | 303e41f4b71Sopenharmony_ci| 202 | The application is not a system application. | 304e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. | 305e41f4b71Sopenharmony_ci| 16500050 | IPC connection error. | 306e41f4b71Sopenharmony_ci| 16500060 | Service connection error. | 307e41f4b71Sopenharmony_ci| 16501000 | An internal functional error occurred. | 308e41f4b71Sopenharmony_ci| 16501001 | The ID of the form to be operated does not exist. | 309e41f4b71Sopenharmony_ci| 16501003 | The form cannot be operated by the current application. | 310e41f4b71Sopenharmony_ci 311e41f4b71Sopenharmony_ci以上错误码的详细介绍请参见[卡片错误码](errorcode-form.md)。 312e41f4b71Sopenharmony_ci 313e41f4b71Sopenharmony_ci**示例:** 314e41f4b71Sopenharmony_ci 315e41f4b71Sopenharmony_ci```ts 316e41f4b71Sopenharmony_ciimport { formHost } from '@kit.FormKit'; 317e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 318e41f4b71Sopenharmony_ci 319e41f4b71Sopenharmony_citry { 320e41f4b71Sopenharmony_ci let formId: string = '12400633174999288'; 321e41f4b71Sopenharmony_ci formHost.requestForm(formId, (error: BusinessError) => { 322e41f4b71Sopenharmony_ci if (error) { 323e41f4b71Sopenharmony_ci console.error(`error, code: ${error.code}, message: ${error.message}`); 324e41f4b71Sopenharmony_ci } 325e41f4b71Sopenharmony_ci }); 326e41f4b71Sopenharmony_ci} catch(error) { 327e41f4b71Sopenharmony_ci console.error(`catch error, code: ${(error as BusinessError).code}, message: ${(error as BusinessError).message}`); 328e41f4b71Sopenharmony_ci} 329e41f4b71Sopenharmony_ci``` 330e41f4b71Sopenharmony_ci 331e41f4b71Sopenharmony_ci## requestForm 332e41f4b71Sopenharmony_ci 333e41f4b71Sopenharmony_cirequestForm(formId: string): Promise<void> 334e41f4b71Sopenharmony_ci 335e41f4b71Sopenharmony_ci请求卡片更新。使用Promise异步回调。 336e41f4b71Sopenharmony_ci 337e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.REQUIRE_FORM 338e41f4b71Sopenharmony_ci 339e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Ability.Form 340e41f4b71Sopenharmony_ci 341e41f4b71Sopenharmony_ci**参数:** 342e41f4b71Sopenharmony_ci 343e41f4b71Sopenharmony_ci| 参数名 | 类型 | 必填 | 说明 | 344e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ------- | 345e41f4b71Sopenharmony_ci| formId | string | 是 | 卡片标识。 | 346e41f4b71Sopenharmony_ci 347e41f4b71Sopenharmony_ci**返回值:** 348e41f4b71Sopenharmony_ci 349e41f4b71Sopenharmony_ci| 类型 | 说明 | 350e41f4b71Sopenharmony_ci| -------- | -------- | 351e41f4b71Sopenharmony_ci| Promise<void> | 无返回结果的Promise对象。 | 352e41f4b71Sopenharmony_ci 353e41f4b71Sopenharmony_ci**错误码:** 354e41f4b71Sopenharmony_ci 355e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 | 356e41f4b71Sopenharmony_ci| -------- | -------- | 357e41f4b71Sopenharmony_ci| 201 | Permissions denied. | 358e41f4b71Sopenharmony_ci| 202 | The application is not a system application. | 359e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. | 360e41f4b71Sopenharmony_ci| 16500050 | IPC connection error. | 361e41f4b71Sopenharmony_ci| 16500060 | Service connection error. | 362e41f4b71Sopenharmony_ci| 16501000 | An internal functional error occurred. | 363e41f4b71Sopenharmony_ci| 16501001 | The ID of the form to be operated does not exist. | 364e41f4b71Sopenharmony_ci| 16501003 | The form cannot be operated by the current application. | 365e41f4b71Sopenharmony_ci 366e41f4b71Sopenharmony_ci以上错误码的详细介绍请参见[卡片错误码](errorcode-form.md)。 367e41f4b71Sopenharmony_ci 368e41f4b71Sopenharmony_ci**示例:** 369e41f4b71Sopenharmony_ci 370e41f4b71Sopenharmony_ci```ts 371e41f4b71Sopenharmony_ciimport { formHost } from '@kit.FormKit'; 372e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 373e41f4b71Sopenharmony_ci 374e41f4b71Sopenharmony_citry { 375e41f4b71Sopenharmony_ci let formId: string = '12400633174999288'; 376e41f4b71Sopenharmony_ci formHost.requestForm(formId).then(() => { 377e41f4b71Sopenharmony_ci console.log('formHost requestForm success'); 378e41f4b71Sopenharmony_ci }).catch((error: BusinessError) => { 379e41f4b71Sopenharmony_ci console.error(`error, code: ${error.code}, message: ${error.message}`); 380e41f4b71Sopenharmony_ci }); 381e41f4b71Sopenharmony_ci} catch(error) { 382e41f4b71Sopenharmony_ci console.error(`catch error, code: ${(error as BusinessError).code}, message: ${(error as BusinessError).message}`); 383e41f4b71Sopenharmony_ci} 384e41f4b71Sopenharmony_ci``` 385e41f4b71Sopenharmony_ci 386e41f4b71Sopenharmony_ci## requestFormWithParams<sup>12+</sup> 387e41f4b71Sopenharmony_ci 388e41f4b71Sopenharmony_cirequestFormWithParams(formId: string, wantParams?: Record<string, Object>): Promise<void> 389e41f4b71Sopenharmony_ci 390e41f4b71Sopenharmony_ci携带参数请求卡片更新。使用Promise异步回调。 391e41f4b71Sopenharmony_ci 392e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.REQUIRE_FORM 393e41f4b71Sopenharmony_ci 394e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Ability.Form 395e41f4b71Sopenharmony_ci 396e41f4b71Sopenharmony_ci**参数:** 397e41f4b71Sopenharmony_ci 398e41f4b71Sopenharmony_ci| 参数名 | 类型 | 必填 | 说明 | 399e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ------- | 400e41f4b71Sopenharmony_ci| formId | string | 是 | 卡片标识。 | 401e41f4b71Sopenharmony_ci| wantParams | Record<string, Object> | 否 | 更新参数。 | 402e41f4b71Sopenharmony_ci 403e41f4b71Sopenharmony_ci**返回值:** 404e41f4b71Sopenharmony_ci 405e41f4b71Sopenharmony_ci| 类型 | 说明 | 406e41f4b71Sopenharmony_ci| -------- | -------- | 407e41f4b71Sopenharmony_ci| Promise<void> | 无返回结果的Promise对象。 | 408e41f4b71Sopenharmony_ci 409e41f4b71Sopenharmony_ci**错误码:** 410e41f4b71Sopenharmony_ci 411e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 | 412e41f4b71Sopenharmony_ci| -------- | -------- | 413e41f4b71Sopenharmony_ci| 201 | Permissions denied. | 414e41f4b71Sopenharmony_ci| 202 | The application is not a system application. | 415e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. | 416e41f4b71Sopenharmony_ci| 16500050 | IPC connection error. | 417e41f4b71Sopenharmony_ci| 16500060 | Service connection error. | 418e41f4b71Sopenharmony_ci| 16501000 | An internal functional error occurred. | 419e41f4b71Sopenharmony_ci| 16501001 | The ID of the form to be operated does not exist. | 420e41f4b71Sopenharmony_ci| 16501003 | The form cannot be operated by the current application. | 421e41f4b71Sopenharmony_ci 422e41f4b71Sopenharmony_ci以上错误码的详细介绍请参见[卡片错误码](errorcode-form.md)。 423e41f4b71Sopenharmony_ci 424e41f4b71Sopenharmony_ci**示例:** 425e41f4b71Sopenharmony_ci 426e41f4b71Sopenharmony_ci```ts 427e41f4b71Sopenharmony_ciimport { formHost } from '@kit.FormKit'; 428e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 429e41f4b71Sopenharmony_ci 430e41f4b71Sopenharmony_citry { 431e41f4b71Sopenharmony_ci let formId: string = '12400633174999288'; 432e41f4b71Sopenharmony_ci let params: Record<string, Object> = { 433e41f4b71Sopenharmony_ci 'ohos.extra.param.key.host_bg_inverse_color': '#ff000000' as Object 434e41f4b71Sopenharmony_ci }; 435e41f4b71Sopenharmony_ci formHost.requestFormWithParams(formId, params).then(() => { 436e41f4b71Sopenharmony_ci console.log('formHost requestFormWithParams success'); 437e41f4b71Sopenharmony_ci }).catch((error: BusinessError) => { 438e41f4b71Sopenharmony_ci console.error(`error, code: ${error.code}, message: ${error.message}`); 439e41f4b71Sopenharmony_ci }); 440e41f4b71Sopenharmony_ci} catch(error) { 441e41f4b71Sopenharmony_ci console.error(`catch error, code: ${(error as BusinessError).code}, message: ${(error as BusinessError).message}`); 442e41f4b71Sopenharmony_ci} 443e41f4b71Sopenharmony_ci``` 444e41f4b71Sopenharmony_ci 445e41f4b71Sopenharmony_ci## castToNormalForm 446e41f4b71Sopenharmony_ci 447e41f4b71Sopenharmony_cicastToNormalForm(formId: string, callback: AsyncCallback<void>): void 448e41f4b71Sopenharmony_ci 449e41f4b71Sopenharmony_ci将指定的临时卡片转换为普通卡片。使用callback异步回调。 450e41f4b71Sopenharmony_ci 451e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.REQUIRE_FORM 452e41f4b71Sopenharmony_ci 453e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Ability.Form 454e41f4b71Sopenharmony_ci 455e41f4b71Sopenharmony_ci**参数:** 456e41f4b71Sopenharmony_ci 457e41f4b71Sopenharmony_ci| 参数名 | 类型 | 必填 | 说明 | 458e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ------- | 459e41f4b71Sopenharmony_ci| formId | string | 是 | 卡片标识。 | 460e41f4b71Sopenharmony_ci| callback | AsyncCallback<void> | 是 | 回调函数。当将指定的临时卡片转换为普通卡片成功,error为undefined,否则为错误对象。 | 461e41f4b71Sopenharmony_ci 462e41f4b71Sopenharmony_ci**错误码:** 463e41f4b71Sopenharmony_ci 464e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 | 465e41f4b71Sopenharmony_ci| -------- | -------- | 466e41f4b71Sopenharmony_ci| 201 | Permissions denied. | 467e41f4b71Sopenharmony_ci| 202 | The application is not a system application. | 468e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. | 469e41f4b71Sopenharmony_ci| 16500050 | IPC connection error. | 470e41f4b71Sopenharmony_ci| 16501000 | An internal functional error occurred. | 471e41f4b71Sopenharmony_ci| 16501001 | The ID of the form to be operated does not exist. | 472e41f4b71Sopenharmony_ci| 16501002 | The number of forms exceeds the maximum allowed. | 473e41f4b71Sopenharmony_ci| 16501003 | The form cannot be operated by the current application. | 474e41f4b71Sopenharmony_ci 475e41f4b71Sopenharmony_ci以上错误码的详细介绍请参见[卡片错误码](errorcode-form.md)。 476e41f4b71Sopenharmony_ci 477e41f4b71Sopenharmony_ci**示例:** 478e41f4b71Sopenharmony_ci 479e41f4b71Sopenharmony_ci```ts 480e41f4b71Sopenharmony_ciimport { formHost } from '@kit.FormKit'; 481e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 482e41f4b71Sopenharmony_ci 483e41f4b71Sopenharmony_citry { 484e41f4b71Sopenharmony_ci let formId: string = '12400633174999288'; 485e41f4b71Sopenharmony_ci formHost.castToNormalForm(formId, (error: BusinessError) => { 486e41f4b71Sopenharmony_ci if (error) { 487e41f4b71Sopenharmony_ci console.error(`error, code: ${error.code}, message: ${error.message}`); 488e41f4b71Sopenharmony_ci } 489e41f4b71Sopenharmony_ci }); 490e41f4b71Sopenharmony_ci} catch(error) { 491e41f4b71Sopenharmony_ci console.error(`catch error, code: ${(error as BusinessError).code}, message: ${(error as BusinessError).message}`); 492e41f4b71Sopenharmony_ci} 493e41f4b71Sopenharmony_ci``` 494e41f4b71Sopenharmony_ci 495e41f4b71Sopenharmony_ci## castToNormalForm 496e41f4b71Sopenharmony_ci 497e41f4b71Sopenharmony_cicastToNormalForm(formId: string): Promise<void> 498e41f4b71Sopenharmony_ci 499e41f4b71Sopenharmony_ci将指定的临时卡片转换为普通卡片。使用Promise异步回调。 500e41f4b71Sopenharmony_ci 501e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.REQUIRE_FORM 502e41f4b71Sopenharmony_ci 503e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Ability.Form 504e41f4b71Sopenharmony_ci 505e41f4b71Sopenharmony_ci**参数:** 506e41f4b71Sopenharmony_ci 507e41f4b71Sopenharmony_ci| 参数名 | 类型 | 必填 | 说明 | 508e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ------- | 509e41f4b71Sopenharmony_ci| formId | string | 是 | 卡片标识。 | 510e41f4b71Sopenharmony_ci 511e41f4b71Sopenharmony_ci**返回值:** 512e41f4b71Sopenharmony_ci 513e41f4b71Sopenharmony_ci| 类型 | 说明 | 514e41f4b71Sopenharmony_ci| -------- | -------- | 515e41f4b71Sopenharmony_ci| Promise<void> | 无返回结果的Promise对象。| 516e41f4b71Sopenharmony_ci 517e41f4b71Sopenharmony_ci**错误码:** 518e41f4b71Sopenharmony_ci 519e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 | 520e41f4b71Sopenharmony_ci| -------- | -------- | 521e41f4b71Sopenharmony_ci| 201 | Permissions denied. | 522e41f4b71Sopenharmony_ci| 202 | The application is not a system application. | 523e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. | 524e41f4b71Sopenharmony_ci| 16500050 | IPC connection error. | 525e41f4b71Sopenharmony_ci| 16501000 | An internal functional error occurred. | 526e41f4b71Sopenharmony_ci| 16501001 | The ID of the form to be operated does not exist. | 527e41f4b71Sopenharmony_ci| 16501002 | The number of forms exceeds the maximum allowed. | 528e41f4b71Sopenharmony_ci| 16501003 | The form cannot be operated by the current application. | 529e41f4b71Sopenharmony_ci 530e41f4b71Sopenharmony_ci以上错误码的详细介绍请参见[卡片错误码](errorcode-form.md)。 531e41f4b71Sopenharmony_ci 532e41f4b71Sopenharmony_ci**示例:** 533e41f4b71Sopenharmony_ci 534e41f4b71Sopenharmony_ci```ts 535e41f4b71Sopenharmony_ciimport { formHost } from '@kit.FormKit'; 536e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 537e41f4b71Sopenharmony_ci 538e41f4b71Sopenharmony_citry { 539e41f4b71Sopenharmony_ci let formId: string = '12400633174999288'; 540e41f4b71Sopenharmony_ci formHost.castToNormalForm(formId).then(() => { 541e41f4b71Sopenharmony_ci console.log('formHost castTempForm success'); 542e41f4b71Sopenharmony_ci }).catch((error: BusinessError) => { 543e41f4b71Sopenharmony_ci console.error(`error, code: ${error.code}, message: ${error.message}`); 544e41f4b71Sopenharmony_ci }); 545e41f4b71Sopenharmony_ci} catch(error) { 546e41f4b71Sopenharmony_ci console.error(`catch error, code: ${(error as BusinessError).code}, message: ${(error as BusinessError).message}`); 547e41f4b71Sopenharmony_ci} 548e41f4b71Sopenharmony_ci``` 549e41f4b71Sopenharmony_ci 550e41f4b71Sopenharmony_ci## notifyVisibleForms 551e41f4b71Sopenharmony_ci 552e41f4b71Sopenharmony_cinotifyVisibleForms(formIds: Array<string>, callback: AsyncCallback<void>): void 553e41f4b71Sopenharmony_ci 554e41f4b71Sopenharmony_ci向卡片框架发送通知以使指定的卡片可见。该方法调用成功后,会调用onVisibilityChange通知卡片提供方。使用callback异步回调。 555e41f4b71Sopenharmony_ci 556e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.REQUIRE_FORM 557e41f4b71Sopenharmony_ci 558e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Ability.Form 559e41f4b71Sopenharmony_ci 560e41f4b71Sopenharmony_ci**参数:** 561e41f4b71Sopenharmony_ci 562e41f4b71Sopenharmony_ci| 参数名 | 类型 | 必填 | 说明 | 563e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ------- | 564e41f4b71Sopenharmony_ci| formIds | Array<string> | 是 | 卡片标识列表。 | 565e41f4b71Sopenharmony_ci| callback | AsyncCallback<void> | 是 | 回调函数。当向卡片框架发送通知以使指定的卡片可见成功,error为undefined,否则为错误对象。 | 566e41f4b71Sopenharmony_ci 567e41f4b71Sopenharmony_ci**错误码:** 568e41f4b71Sopenharmony_ci 569e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 | 570e41f4b71Sopenharmony_ci| -------- | -------- | 571e41f4b71Sopenharmony_ci| 201 | Permissions denied. | 572e41f4b71Sopenharmony_ci| 202 | The application is not a system application. | 573e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. | 574e41f4b71Sopenharmony_ci| 16500050 | IPC connection error. | 575e41f4b71Sopenharmony_ci| 16500060 | Service connection error. | 576e41f4b71Sopenharmony_ci| 16501000 | An internal functional error occurred. | 577e41f4b71Sopenharmony_ci 578e41f4b71Sopenharmony_ci以上错误码的详细介绍请参见[卡片错误码](errorcode-form.md)。 579e41f4b71Sopenharmony_ci 580e41f4b71Sopenharmony_ci**示例:** 581e41f4b71Sopenharmony_ci 582e41f4b71Sopenharmony_ci```ts 583e41f4b71Sopenharmony_ciimport { formHost } from '@kit.FormKit'; 584e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 585e41f4b71Sopenharmony_ci 586e41f4b71Sopenharmony_citry { 587e41f4b71Sopenharmony_ci let formId: string[] = ['12400633174999288']; 588e41f4b71Sopenharmony_ci formHost.notifyVisibleForms(formId, (error: BusinessError) => { 589e41f4b71Sopenharmony_ci if (error) { 590e41f4b71Sopenharmony_ci console.error(`error, code: ${error.code}, message: ${error.message}`); 591e41f4b71Sopenharmony_ci } 592e41f4b71Sopenharmony_ci }); 593e41f4b71Sopenharmony_ci} catch (error) { 594e41f4b71Sopenharmony_ci console.error(`catch error, code: ${(error as BusinessError).code}, message: ${(error as BusinessError).message}`); 595e41f4b71Sopenharmony_ci} 596e41f4b71Sopenharmony_ci``` 597e41f4b71Sopenharmony_ci 598e41f4b71Sopenharmony_ci## notifyVisibleForms 599e41f4b71Sopenharmony_ci 600e41f4b71Sopenharmony_cinotifyVisibleForms(formIds: Array<string>): Promise<void> 601e41f4b71Sopenharmony_ci 602e41f4b71Sopenharmony_ci向卡片框架发送通知以使指定的卡片可见。该方法调用成功后,会调用onVisibilityChange通知卡片提供方。使用Promise异步回调。 603e41f4b71Sopenharmony_ci 604e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.REQUIRE_FORM 605e41f4b71Sopenharmony_ci 606e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Ability.Form 607e41f4b71Sopenharmony_ci 608e41f4b71Sopenharmony_ci**参数:** 609e41f4b71Sopenharmony_ci 610e41f4b71Sopenharmony_ci| 参数名 | 类型 | 必填 | 说明 | 611e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ------- | 612e41f4b71Sopenharmony_ci| formIds | Array<string> | 是 | 卡片标识列表。 | 613e41f4b71Sopenharmony_ci 614e41f4b71Sopenharmony_ci**返回值:** 615e41f4b71Sopenharmony_ci 616e41f4b71Sopenharmony_ci| 类型 | 说明 | 617e41f4b71Sopenharmony_ci| -------- | -------- | 618e41f4b71Sopenharmony_ci| Promise<void> | 无返回结果的Promise对象。 | 619e41f4b71Sopenharmony_ci 620e41f4b71Sopenharmony_ci**错误码:** 621e41f4b71Sopenharmony_ci 622e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 | 623e41f4b71Sopenharmony_ci| -------- | -------- | 624e41f4b71Sopenharmony_ci| 201 | Permissions denied. | 625e41f4b71Sopenharmony_ci| 202 | The application is not a system application. | 626e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. | 627e41f4b71Sopenharmony_ci| 16500050 | IPC connection error. | 628e41f4b71Sopenharmony_ci| 16500060 | Service connection error. | 629e41f4b71Sopenharmony_ci| 16501000 | An internal functional error occurred. | 630e41f4b71Sopenharmony_ci 631e41f4b71Sopenharmony_ci以上错误码的详细介绍请参见[卡片错误码](errorcode-form.md)。 632e41f4b71Sopenharmony_ci 633e41f4b71Sopenharmony_ci**示例:** 634e41f4b71Sopenharmony_ci 635e41f4b71Sopenharmony_ci```ts 636e41f4b71Sopenharmony_ciimport { formHost } from '@kit.FormKit'; 637e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 638e41f4b71Sopenharmony_ci 639e41f4b71Sopenharmony_citry { 640e41f4b71Sopenharmony_ci let formId: string[] = ['12400633174999288']; 641e41f4b71Sopenharmony_ci formHost.notifyVisibleForms(formId).then(() => { 642e41f4b71Sopenharmony_ci console.log('formHost notifyVisibleForms success'); 643e41f4b71Sopenharmony_ci }).catch((error: BusinessError) => { 644e41f4b71Sopenharmony_ci console.error(`error, code: ${error.code}, message: ${error.message}`); 645e41f4b71Sopenharmony_ci }); 646e41f4b71Sopenharmony_ci} catch(error) { 647e41f4b71Sopenharmony_ci console.error(`catch error, code: ${(error as BusinessError).code}, message: ${(error as BusinessError).message}`); 648e41f4b71Sopenharmony_ci} 649e41f4b71Sopenharmony_ci``` 650e41f4b71Sopenharmony_ci 651e41f4b71Sopenharmony_ci## notifyInvisibleForms 652e41f4b71Sopenharmony_ci 653e41f4b71Sopenharmony_cinotifyInvisibleForms(formIds: Array<string>, callback: AsyncCallback<void>): void 654e41f4b71Sopenharmony_ci 655e41f4b71Sopenharmony_ci向卡片框架发送通知以使指定的卡片不可见。该方法调用成功后,会调用onVisibilityChange通知卡片提供方。使用callback异步回调。 656e41f4b71Sopenharmony_ci 657e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.REQUIRE_FORM 658e41f4b71Sopenharmony_ci 659e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Ability.Form 660e41f4b71Sopenharmony_ci 661e41f4b71Sopenharmony_ci**参数:** 662e41f4b71Sopenharmony_ci 663e41f4b71Sopenharmony_ci| 参数名 | 类型 | 必填 | 说明 | 664e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ------- | 665e41f4b71Sopenharmony_ci| formIds | Array<string> | 是 | 卡片标识列表。| 666e41f4b71Sopenharmony_ci| callback | AsyncCallback<void> | 是 | 回调函数。当向卡片框架发送通知以使指定的卡片不可见成功,error为undefined,否则为错误对象。 | 667e41f4b71Sopenharmony_ci 668e41f4b71Sopenharmony_ci**错误码:** 669e41f4b71Sopenharmony_ci 670e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 | 671e41f4b71Sopenharmony_ci| -------- | -------- | 672e41f4b71Sopenharmony_ci| 201 | Permissions denied. | 673e41f4b71Sopenharmony_ci| 202 | The application is not a system application. | 674e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. | 675e41f4b71Sopenharmony_ci| 16500050 | IPC connection error. | 676e41f4b71Sopenharmony_ci| 16500060 | Service connection error. | 677e41f4b71Sopenharmony_ci| 16501000 | An internal functional error occurred. | 678e41f4b71Sopenharmony_ci 679e41f4b71Sopenharmony_ci以上错误码的详细介绍请参见[卡片错误码](errorcode-form.md)。 680e41f4b71Sopenharmony_ci 681e41f4b71Sopenharmony_ci**示例:** 682e41f4b71Sopenharmony_ci 683e41f4b71Sopenharmony_ci```ts 684e41f4b71Sopenharmony_ciimport { formHost } from '@kit.FormKit'; 685e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 686e41f4b71Sopenharmony_ci 687e41f4b71Sopenharmony_citry { 688e41f4b71Sopenharmony_ci let formId: string[] = ['12400633174999288']; 689e41f4b71Sopenharmony_ci formHost.notifyInvisibleForms(formId, (error: BusinessError) => { 690e41f4b71Sopenharmony_ci if (error) { 691e41f4b71Sopenharmony_ci console.error(`error, code: ${error.code}, message: ${error.message}`); 692e41f4b71Sopenharmony_ci } 693e41f4b71Sopenharmony_ci }); 694e41f4b71Sopenharmony_ci} catch(error) { 695e41f4b71Sopenharmony_ci console.error(`catch error, code: ${(error as BusinessError).code}, message: ${(error as BusinessError).message}`); 696e41f4b71Sopenharmony_ci} 697e41f4b71Sopenharmony_ci``` 698e41f4b71Sopenharmony_ci 699e41f4b71Sopenharmony_ci## notifyInvisibleForms 700e41f4b71Sopenharmony_ci 701e41f4b71Sopenharmony_cinotifyInvisibleForms(formIds: Array<string>): Promise<void> 702e41f4b71Sopenharmony_ci 703e41f4b71Sopenharmony_ci向卡片框架发送通知以使指定的卡片不可见。该方法调用成功后,会调用onVisibilityChange通知卡片提供方。使用Promise异步回调。 704e41f4b71Sopenharmony_ci 705e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.REQUIRE_FORM 706e41f4b71Sopenharmony_ci 707e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Ability.Form 708e41f4b71Sopenharmony_ci 709e41f4b71Sopenharmony_ci**参数:** 710e41f4b71Sopenharmony_ci 711e41f4b71Sopenharmony_ci| 参数名 | 类型 | 必填 | 说明 | 712e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ------- | 713e41f4b71Sopenharmony_ci| formIds | Array<string> | 是 | 卡片标识列表。 | 714e41f4b71Sopenharmony_ci 715e41f4b71Sopenharmony_ci**返回值:** 716e41f4b71Sopenharmony_ci 717e41f4b71Sopenharmony_ci| 类型 | 说明 | 718e41f4b71Sopenharmony_ci| -------- | -------- | 719e41f4b71Sopenharmony_ci| Promise<void> | 无返回结果的Promise对象。| 720e41f4b71Sopenharmony_ci 721e41f4b71Sopenharmony_ci**错误码:** 722e41f4b71Sopenharmony_ci 723e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 | 724e41f4b71Sopenharmony_ci| -------- | -------- | 725e41f4b71Sopenharmony_ci| 201 | Permissions denied. | 726e41f4b71Sopenharmony_ci| 202 | The application is not a system application. | 727e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. | 728e41f4b71Sopenharmony_ci| 16500050 | IPC connection error. | 729e41f4b71Sopenharmony_ci| 16500060 | Service connection error. | 730e41f4b71Sopenharmony_ci| 16501000 | An internal functional error occurred. | 731e41f4b71Sopenharmony_ci 732e41f4b71Sopenharmony_ci以上错误码的详细介绍请参见[卡片错误码](errorcode-form.md)。 733e41f4b71Sopenharmony_ci 734e41f4b71Sopenharmony_ci**示例:** 735e41f4b71Sopenharmony_ci 736e41f4b71Sopenharmony_ci```ts 737e41f4b71Sopenharmony_ciimport { formHost } from '@kit.FormKit'; 738e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 739e41f4b71Sopenharmony_ci 740e41f4b71Sopenharmony_citry { 741e41f4b71Sopenharmony_ci let formId: string[] = ['12400633174999288']; 742e41f4b71Sopenharmony_ci formHost.notifyInvisibleForms(formId).then(() => { 743e41f4b71Sopenharmony_ci console.log('formHost notifyInvisibleForms success'); 744e41f4b71Sopenharmony_ci }).catch((error: BusinessError) => { 745e41f4b71Sopenharmony_ci console.error(`error, code: ${error.code}, message: ${error.message}`); 746e41f4b71Sopenharmony_ci }); 747e41f4b71Sopenharmony_ci} catch(error) { 748e41f4b71Sopenharmony_ci console.error(`catch error, code: ${(error as BusinessError).code}, message: ${(error as BusinessError).message}`); 749e41f4b71Sopenharmony_ci} 750e41f4b71Sopenharmony_ci``` 751e41f4b71Sopenharmony_ci 752e41f4b71Sopenharmony_ci## enableFormsUpdate 753e41f4b71Sopenharmony_ci 754e41f4b71Sopenharmony_cienableFormsUpdate(formIds: Array<string>, callback: AsyncCallback<void>): void 755e41f4b71Sopenharmony_ci 756e41f4b71Sopenharmony_ci向卡片框架发送通知以使指定的卡片可以更新。该方法调用成功后,卡片刷新状态设置为使能,卡片可以接收来自卡片提供方的更新。使用callback异步回调。 757e41f4b71Sopenharmony_ci 758e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.REQUIRE_FORM 759e41f4b71Sopenharmony_ci 760e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Ability.Form 761e41f4b71Sopenharmony_ci 762e41f4b71Sopenharmony_ci**参数:** 763e41f4b71Sopenharmony_ci 764e41f4b71Sopenharmony_ci| 参数名 | 类型 | 必填 | 说明 | 765e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ------- | 766e41f4b71Sopenharmony_ci| formIds | Array<string> | 是 | 卡片标识列表。 | 767e41f4b71Sopenharmony_ci| callback | AsyncCallback<void> | 是 | 回调函数。当向卡片框架发送通知以使指定的卡片可以更新成功,error为undefined,否则为错误对象。 | 768e41f4b71Sopenharmony_ci 769e41f4b71Sopenharmony_ci**错误码:** 770e41f4b71Sopenharmony_ci 771e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 | 772e41f4b71Sopenharmony_ci| -------- | -------- | 773e41f4b71Sopenharmony_ci| 201 | Permissions denied. | 774e41f4b71Sopenharmony_ci| 202 | The application is not a system application. | 775e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. | 776e41f4b71Sopenharmony_ci| 16500050 | IPC connection error. | 777e41f4b71Sopenharmony_ci| 16500060 | Service connection error. | 778e41f4b71Sopenharmony_ci| 16501000 | An internal functional error occurred. | 779e41f4b71Sopenharmony_ci| 16501003 | The form cannot be operated by the current application. | 780e41f4b71Sopenharmony_ci 781e41f4b71Sopenharmony_ci以上错误码的详细介绍请参见[卡片错误码](errorcode-form.md)。 782e41f4b71Sopenharmony_ci 783e41f4b71Sopenharmony_ci**示例:** 784e41f4b71Sopenharmony_ci 785e41f4b71Sopenharmony_ci```ts 786e41f4b71Sopenharmony_ciimport { formHost } from '@kit.FormKit'; 787e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 788e41f4b71Sopenharmony_ci 789e41f4b71Sopenharmony_citry { 790e41f4b71Sopenharmony_ci let formId: string[] = ['12400633174999288']; 791e41f4b71Sopenharmony_ci formHost.enableFormsUpdate(formId, (error: BusinessError) => { 792e41f4b71Sopenharmony_ci if (error) { 793e41f4b71Sopenharmony_ci console.error(`error, code: ${error.code}, message: ${error.message}`); 794e41f4b71Sopenharmony_ci } 795e41f4b71Sopenharmony_ci }); 796e41f4b71Sopenharmony_ci} catch(error) { 797e41f4b71Sopenharmony_ci console.error(`catch error, code: ${(error as BusinessError).code}, message: ${(error as BusinessError).message}`); 798e41f4b71Sopenharmony_ci} 799e41f4b71Sopenharmony_ci``` 800e41f4b71Sopenharmony_ci 801e41f4b71Sopenharmony_ci## enableFormsUpdate 802e41f4b71Sopenharmony_ci 803e41f4b71Sopenharmony_cienableFormsUpdate(formIds: Array<string>): Promise<void> 804e41f4b71Sopenharmony_ci 805e41f4b71Sopenharmony_ci向卡片框架发送通知以使指定的卡片可以更新。该方法调用成功后,卡片刷新状态设置为使能,卡片可以接收来自卡片提供方的更新。使用Promise异步回调。 806e41f4b71Sopenharmony_ci 807e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.REQUIRE_FORM 808e41f4b71Sopenharmony_ci 809e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Ability.Form 810e41f4b71Sopenharmony_ci 811e41f4b71Sopenharmony_ci**参数:** 812e41f4b71Sopenharmony_ci 813e41f4b71Sopenharmony_ci| 参数名 | 类型 | 必填 | 说明 | 814e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ------- | 815e41f4b71Sopenharmony_ci| formIds | Array<string> | 是 | 卡片标识列表。 | 816e41f4b71Sopenharmony_ci 817e41f4b71Sopenharmony_ci**返回值:** 818e41f4b71Sopenharmony_ci 819e41f4b71Sopenharmony_ci| 类型 | 说明 | 820e41f4b71Sopenharmony_ci| -------- | -------- | 821e41f4b71Sopenharmony_ci| Promise<void> | 无返回结果的Promise对象。 | 822e41f4b71Sopenharmony_ci 823e41f4b71Sopenharmony_ci**错误码:** 824e41f4b71Sopenharmony_ci 825e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 | 826e41f4b71Sopenharmony_ci| -------- | -------- | 827e41f4b71Sopenharmony_ci| 201 | Permissions denied. | 828e41f4b71Sopenharmony_ci| 202 | The application is not a system application. | 829e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. | 830e41f4b71Sopenharmony_ci| 16500050 | IPC connection error. | 831e41f4b71Sopenharmony_ci| 16500060 | Service connection error. | 832e41f4b71Sopenharmony_ci| 16501000 | An internal functional error occurred. | 833e41f4b71Sopenharmony_ci| 16501003 | The form cannot be operated by the current application. | 834e41f4b71Sopenharmony_ci 835e41f4b71Sopenharmony_ci以上错误码的详细介绍请参见[卡片错误码](errorcode-form.md)。 836e41f4b71Sopenharmony_ci 837e41f4b71Sopenharmony_ci**示例:** 838e41f4b71Sopenharmony_ci 839e41f4b71Sopenharmony_ci```ts 840e41f4b71Sopenharmony_ciimport { formHost } from '@kit.FormKit'; 841e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 842e41f4b71Sopenharmony_ci 843e41f4b71Sopenharmony_citry { 844e41f4b71Sopenharmony_ci let formId: string[] = ['12400633174999288']; 845e41f4b71Sopenharmony_ci formHost.enableFormsUpdate(formId).then(() => { 846e41f4b71Sopenharmony_ci console.log('formHost enableFormsUpdate success'); 847e41f4b71Sopenharmony_ci }).catch((error: BusinessError) => { 848e41f4b71Sopenharmony_ci console.error(`error, code: ${error.code}, message: ${error.message}`); 849e41f4b71Sopenharmony_ci }); 850e41f4b71Sopenharmony_ci} catch(error) { 851e41f4b71Sopenharmony_ci console.error(`catch error, code: ${(error as BusinessError).code}, message: ${(error as BusinessError).message}`); 852e41f4b71Sopenharmony_ci} 853e41f4b71Sopenharmony_ci``` 854e41f4b71Sopenharmony_ci 855e41f4b71Sopenharmony_ci## disableFormsUpdate 856e41f4b71Sopenharmony_ci 857e41f4b71Sopenharmony_cidisableFormsUpdate(formIds: Array<string>, callback: AsyncCallback<void>): void 858e41f4b71Sopenharmony_ci 859e41f4b71Sopenharmony_ci向卡片框架发送通知以使指定的卡片不可以更新。该方法调用成功后,卡片刷新状态设置为去使能,卡片不可以接收来自卡片提供方的更新。使用callback异步回调。 860e41f4b71Sopenharmony_ci 861e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.REQUIRE_FORM 862e41f4b71Sopenharmony_ci 863e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Ability.Form 864e41f4b71Sopenharmony_ci 865e41f4b71Sopenharmony_ci**参数:** 866e41f4b71Sopenharmony_ci 867e41f4b71Sopenharmony_ci| 参数名 | 类型 | 必填 | 说明 | 868e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ------- | 869e41f4b71Sopenharmony_ci| formIds | Array<string> | 是 | 卡片标识列表。 | 870e41f4b71Sopenharmony_ci| callback | AsyncCallback<void> | 是 | 回调函数。当向卡片框架发送通知以使指定的卡片不可以更新成功,error为undefined,否则为错误对象。 | 871e41f4b71Sopenharmony_ci 872e41f4b71Sopenharmony_ci**错误码:** 873e41f4b71Sopenharmony_ci 874e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 | 875e41f4b71Sopenharmony_ci| -------- | -------- | 876e41f4b71Sopenharmony_ci| 201 | Permissions denied. | 877e41f4b71Sopenharmony_ci| 202 | The application is not a system application. | 878e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. | 879e41f4b71Sopenharmony_ci| 16500050 | IPC connection error. | 880e41f4b71Sopenharmony_ci| 16500060 | Service connection error. | 881e41f4b71Sopenharmony_ci| 16501000 | An internal functional error occurred. | 882e41f4b71Sopenharmony_ci| 16501001 | The ID of the form to be operated does not exist. | 883e41f4b71Sopenharmony_ci| 16501003 | The form cannot be operated by the current application. | 884e41f4b71Sopenharmony_ci 885e41f4b71Sopenharmony_ci以上错误码的详细介绍请参见[卡片错误码](errorcode-form.md)。 886e41f4b71Sopenharmony_ci 887e41f4b71Sopenharmony_ci**示例:** 888e41f4b71Sopenharmony_ci 889e41f4b71Sopenharmony_ci```ts 890e41f4b71Sopenharmony_ciimport { formHost } from '@kit.FormKit'; 891e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 892e41f4b71Sopenharmony_ci 893e41f4b71Sopenharmony_citry { 894e41f4b71Sopenharmony_ci let formId: string[] = ['12400633174999288']; 895e41f4b71Sopenharmony_ci formHost.disableFormsUpdate(formId, (error: BusinessError) => { 896e41f4b71Sopenharmony_ci if (error) { 897e41f4b71Sopenharmony_ci console.error(`error, code: ${error.code}, message: ${error.message}`); 898e41f4b71Sopenharmony_ci } 899e41f4b71Sopenharmony_ci }); 900e41f4b71Sopenharmony_ci} catch(error) { 901e41f4b71Sopenharmony_ci console.error(`catch error, code: ${(error as BusinessError).code}, message: ${(error as BusinessError).message}`); 902e41f4b71Sopenharmony_ci} 903e41f4b71Sopenharmony_ci``` 904e41f4b71Sopenharmony_ci 905e41f4b71Sopenharmony_ci## disableFormsUpdate 906e41f4b71Sopenharmony_ci 907e41f4b71Sopenharmony_cidisableFormsUpdate(formIds: Array<string>): Promise<void> 908e41f4b71Sopenharmony_ci 909e41f4b71Sopenharmony_ci向卡片框架发送通知以使指定的卡片不可以更新。该方法调用成功后,卡片刷新状态设置为去使能,卡片不可以接收来自卡片提供方的更新。使用Promise异步回调。 910e41f4b71Sopenharmony_ci 911e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.REQUIRE_FORM 912e41f4b71Sopenharmony_ci 913e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Ability.Form 914e41f4b71Sopenharmony_ci 915e41f4b71Sopenharmony_ci**参数:** 916e41f4b71Sopenharmony_ci 917e41f4b71Sopenharmony_ci| 参数名 | 类型 | 必填 | 说明 | 918e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ------- | 919e41f4b71Sopenharmony_ci| formIds | Array<string> | 是 | 卡片标识列表。 | 920e41f4b71Sopenharmony_ci 921e41f4b71Sopenharmony_ci**返回值:** 922e41f4b71Sopenharmony_ci 923e41f4b71Sopenharmony_ci| 类型 | 说明 | 924e41f4b71Sopenharmony_ci| -------- | -------- | 925e41f4b71Sopenharmony_ci| Promise<void> | 无返回结果的Promise对象。 | 926e41f4b71Sopenharmony_ci 927e41f4b71Sopenharmony_ci**错误码:** 928e41f4b71Sopenharmony_ci 929e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 | 930e41f4b71Sopenharmony_ci| -------- | -------- | 931e41f4b71Sopenharmony_ci| 201 | Permissions denied. | 932e41f4b71Sopenharmony_ci| 202 | The application is not a system application. | 933e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. | 934e41f4b71Sopenharmony_ci| 16500050 | IPC connection error. | 935e41f4b71Sopenharmony_ci| 16500060 | Service connection error. | 936e41f4b71Sopenharmony_ci| 16501000 | An internal functional error occurred. | 937e41f4b71Sopenharmony_ci| 16501001 | The ID of the form to be operated does not exist. | 938e41f4b71Sopenharmony_ci| 16501003 | The form cannot be operated by the current application. | 939e41f4b71Sopenharmony_ci 940e41f4b71Sopenharmony_ci以上错误码的详细介绍请参见[卡片错误码](errorcode-form.md)。 941e41f4b71Sopenharmony_ci 942e41f4b71Sopenharmony_ci**示例:** 943e41f4b71Sopenharmony_ci 944e41f4b71Sopenharmony_ci```ts 945e41f4b71Sopenharmony_ciimport { formHost } from '@kit.FormKit'; 946e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 947e41f4b71Sopenharmony_ci 948e41f4b71Sopenharmony_citry { 949e41f4b71Sopenharmony_ci let formId: string[] = ['12400633174999288']; 950e41f4b71Sopenharmony_ci formHost.disableFormsUpdate(formId).then(() => { 951e41f4b71Sopenharmony_ci console.log('formHost disableFormsUpdate success'); 952e41f4b71Sopenharmony_ci }).catch((error: BusinessError) => { 953e41f4b71Sopenharmony_ci console.error(`error, code: ${error.code}, message: ${error.message}`); 954e41f4b71Sopenharmony_ci }); 955e41f4b71Sopenharmony_ci} catch(error) { 956e41f4b71Sopenharmony_ci console.error(`catch error, code: ${(error as BusinessError).code}, message: ${(error as BusinessError).message}`); 957e41f4b71Sopenharmony_ci} 958e41f4b71Sopenharmony_ci``` 959e41f4b71Sopenharmony_ci 960e41f4b71Sopenharmony_ci## isSystemReady 961e41f4b71Sopenharmony_ci 962e41f4b71Sopenharmony_ciisSystemReady(callback: AsyncCallback<void>): void 963e41f4b71Sopenharmony_ci 964e41f4b71Sopenharmony_ci检查系统是否准备好。使用callback异步回调。 965e41f4b71Sopenharmony_ci 966e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Ability.Form 967e41f4b71Sopenharmony_ci 968e41f4b71Sopenharmony_ci**参数:** 969e41f4b71Sopenharmony_ci 970e41f4b71Sopenharmony_ci| 参数名 | 类型 | 必填 | 说明 | 971e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ------- | 972e41f4b71Sopenharmony_ci| callback | AsyncCallback<void> | 是 | 回调函数。当检查系统是否准备好成功,error为undefined,否则为错误对象。 | 973e41f4b71Sopenharmony_ci 974e41f4b71Sopenharmony_ci**错误码:** 975e41f4b71Sopenharmony_ci 976e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 | 977e41f4b71Sopenharmony_ci| -------- | -------- | 978e41f4b71Sopenharmony_ci| 202 | The application is not a system application. | 979e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. | 980e41f4b71Sopenharmony_ci 981e41f4b71Sopenharmony_ci以上错误码的详细介绍请参见[卡片错误码](errorcode-form.md)。 982e41f4b71Sopenharmony_ci 983e41f4b71Sopenharmony_ci**示例:** 984e41f4b71Sopenharmony_ci 985e41f4b71Sopenharmony_ci```ts 986e41f4b71Sopenharmony_ciimport { formHost } from '@kit.FormKit'; 987e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 988e41f4b71Sopenharmony_ci 989e41f4b71Sopenharmony_citry { 990e41f4b71Sopenharmony_ci formHost.isSystemReady((error: BusinessError) => { 991e41f4b71Sopenharmony_ci if (error) { 992e41f4b71Sopenharmony_ci console.error(`error, code: ${error.code}, message: ${error.message}`); 993e41f4b71Sopenharmony_ci } 994e41f4b71Sopenharmony_ci }); 995e41f4b71Sopenharmony_ci} catch(error) { 996e41f4b71Sopenharmony_ci console.error(`catch error, code: ${(error as BusinessError).code}, message: ${(error as BusinessError).message}`); 997e41f4b71Sopenharmony_ci} 998e41f4b71Sopenharmony_ci``` 999e41f4b71Sopenharmony_ci 1000e41f4b71Sopenharmony_ci## isSystemReady 1001e41f4b71Sopenharmony_ci 1002e41f4b71Sopenharmony_ciisSystemReady(): Promise<void> 1003e41f4b71Sopenharmony_ci 1004e41f4b71Sopenharmony_ci检查系统是否准备好。使用Promise异步回调。 1005e41f4b71Sopenharmony_ci 1006e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Ability.Form 1007e41f4b71Sopenharmony_ci 1008e41f4b71Sopenharmony_ci**返回值:** 1009e41f4b71Sopenharmony_ci 1010e41f4b71Sopenharmony_ci| 类型 | 说明 | 1011e41f4b71Sopenharmony_ci| -------- | -------- | 1012e41f4b71Sopenharmony_ci| Promise<void> | 无返回结果的Promise对象。 | 1013e41f4b71Sopenharmony_ci 1014e41f4b71Sopenharmony_ci**错误码:** 1015e41f4b71Sopenharmony_ci 1016e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 | 1017e41f4b71Sopenharmony_ci| -------- | -------- | 1018e41f4b71Sopenharmony_ci| 202 | The application is not a system application. | 1019e41f4b71Sopenharmony_ci 1020e41f4b71Sopenharmony_ci以上错误码的详细介绍请参见[卡片错误码](errorcode-form.md)。 1021e41f4b71Sopenharmony_ci 1022e41f4b71Sopenharmony_ci**示例:** 1023e41f4b71Sopenharmony_ci 1024e41f4b71Sopenharmony_ci```ts 1025e41f4b71Sopenharmony_ciimport { formHost } from '@kit.FormKit'; 1026e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 1027e41f4b71Sopenharmony_ci 1028e41f4b71Sopenharmony_citry { 1029e41f4b71Sopenharmony_ci formHost.isSystemReady().then(() => { 1030e41f4b71Sopenharmony_ci console.log('formHost isSystemReady success'); 1031e41f4b71Sopenharmony_ci }).catch((error: BusinessError) => { 1032e41f4b71Sopenharmony_ci console.error(`error, code: ${error.code}, message: ${error.message}`); 1033e41f4b71Sopenharmony_ci }); 1034e41f4b71Sopenharmony_ci} catch(error) { 1035e41f4b71Sopenharmony_ci console.error(`catch error, code: ${(error as BusinessError).code}, message: ${(error as BusinessError).message}`); 1036e41f4b71Sopenharmony_ci} 1037e41f4b71Sopenharmony_ci``` 1038e41f4b71Sopenharmony_ci 1039e41f4b71Sopenharmony_ci## getAllFormsInfo 1040e41f4b71Sopenharmony_ci 1041e41f4b71Sopenharmony_cigetAllFormsInfo(callback: AsyncCallback<Array<formInfo.FormInfo>>): void 1042e41f4b71Sopenharmony_ci 1043e41f4b71Sopenharmony_ci获取设备上所有应用提供的卡片信息。使用callback异步回调。 1044e41f4b71Sopenharmony_ci 1045e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 1046e41f4b71Sopenharmony_ci 1047e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Ability.Form 1048e41f4b71Sopenharmony_ci 1049e41f4b71Sopenharmony_ci**参数:** 1050e41f4b71Sopenharmony_ci 1051e41f4b71Sopenharmony_ci| 参数名 | 类型 | 必填 | 说明 | 1052e41f4b71Sopenharmony_ci| ------ |----------------------------------------------------------------------------------------------| ---- | ------- | 1053e41f4b71Sopenharmony_ci| callback | AsyncCallback<Array<[formInfo.FormInfo](js-apis-app-form-formInfo.md#forminfo)>> | 是 | 回调函数。当获取设备上所有应用提供的卡片信息成功,error为undefined,data为查询到的卡片信息;否则为错误对象。 | 1054e41f4b71Sopenharmony_ci 1055e41f4b71Sopenharmony_ci**错误码:** 1056e41f4b71Sopenharmony_ci 1057e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 | 1058e41f4b71Sopenharmony_ci| -------- | -------- | 1059e41f4b71Sopenharmony_ci| 201 | Permissions denied. | 1060e41f4b71Sopenharmony_ci| 202 | The application is not a system application. | 1061e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. | 1062e41f4b71Sopenharmony_ci| 16500050 | IPC connection error. | 1063e41f4b71Sopenharmony_ci| 16500060 | Service connection error. | 1064e41f4b71Sopenharmony_ci| 16501000 | An internal functional error occurred. | 1065e41f4b71Sopenharmony_ci 1066e41f4b71Sopenharmony_ci以上错误码的详细介绍请参见[卡片错误码](errorcode-form.md)。 1067e41f4b71Sopenharmony_ci 1068e41f4b71Sopenharmony_ci 1069e41f4b71Sopenharmony_ci**示例:** 1070e41f4b71Sopenharmony_ci 1071e41f4b71Sopenharmony_ci```ts 1072e41f4b71Sopenharmony_ciimport { formHost, formInfo } from '@kit.FormKit'; 1073e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 1074e41f4b71Sopenharmony_ci 1075e41f4b71Sopenharmony_citry { 1076e41f4b71Sopenharmony_ci formHost.getAllFormsInfo((error: BusinessError, data: formInfo.FormInfo[]) => { 1077e41f4b71Sopenharmony_ci if (error) { 1078e41f4b71Sopenharmony_ci console.error(`error, code: ${error.code}, message: ${error.message}`); 1079e41f4b71Sopenharmony_ci } else { 1080e41f4b71Sopenharmony_ci console.log(`formHost getAllFormsInfo, data: ${JSON.stringify(data)}`); 1081e41f4b71Sopenharmony_ci } 1082e41f4b71Sopenharmony_ci }); 1083e41f4b71Sopenharmony_ci} catch(error) { 1084e41f4b71Sopenharmony_ci console.error(`catch error, code: ${(error as BusinessError).code}, message: ${(error as BusinessError).message}`); 1085e41f4b71Sopenharmony_ci} 1086e41f4b71Sopenharmony_ci``` 1087e41f4b71Sopenharmony_ci 1088e41f4b71Sopenharmony_ci## getAllFormsInfo 1089e41f4b71Sopenharmony_ci 1090e41f4b71Sopenharmony_cigetAllFormsInfo(): Promise<Array<formInfo.FormInfo>> 1091e41f4b71Sopenharmony_ci 1092e41f4b71Sopenharmony_ci获取设备上所有应用提供的卡片信息。使用Promise异步回调。 1093e41f4b71Sopenharmony_ci 1094e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 1095e41f4b71Sopenharmony_ci 1096e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Ability.Form 1097e41f4b71Sopenharmony_ci 1098e41f4b71Sopenharmony_ci**返回值:** 1099e41f4b71Sopenharmony_ci 1100e41f4b71Sopenharmony_ci| 类型 | 说明 | 1101e41f4b71Sopenharmony_ci|:---------------------------------------------------------------------------------------|:----------------------| 1102e41f4b71Sopenharmony_ci| Promise<Array<[formInfo.FormInfo](js-apis-app-form-formInfo.md#forminfo)>> | Promise对象。返回查询到的卡片信息。 | 1103e41f4b71Sopenharmony_ci 1104e41f4b71Sopenharmony_ci**错误码:** 1105e41f4b71Sopenharmony_ci 1106e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 | 1107e41f4b71Sopenharmony_ci| -------- | -------- | 1108e41f4b71Sopenharmony_ci| 201 | Permissions denied. | 1109e41f4b71Sopenharmony_ci| 202 | The application is not a system application. | 1110e41f4b71Sopenharmony_ci| 16500050 | IPC connection error. | 1111e41f4b71Sopenharmony_ci| 16500060 | Service connection error. | 1112e41f4b71Sopenharmony_ci| 16501000 | An internal functional error occurred. | 1113e41f4b71Sopenharmony_ci 1114e41f4b71Sopenharmony_ci以上错误码的详细介绍请参见[卡片错误码](errorcode-form.md)。 1115e41f4b71Sopenharmony_ci 1116e41f4b71Sopenharmony_ci**示例:** 1117e41f4b71Sopenharmony_ci 1118e41f4b71Sopenharmony_ci```ts 1119e41f4b71Sopenharmony_ciimport { formHost, formInfo } from '@kit.FormKit'; 1120e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 1121e41f4b71Sopenharmony_ci 1122e41f4b71Sopenharmony_citry { 1123e41f4b71Sopenharmony_ci formHost.getAllFormsInfo().then((data: formInfo.FormInfo[]) => { 1124e41f4b71Sopenharmony_ci console.log(`formHost getAllFormsInfo data: ${JSON.stringify(data)}`); 1125e41f4b71Sopenharmony_ci }).catch((error: BusinessError) => { 1126e41f4b71Sopenharmony_ci console.error(`error, code: ${error.code}, message: ${error.message}`); 1127e41f4b71Sopenharmony_ci }); 1128e41f4b71Sopenharmony_ci} catch(error) { 1129e41f4b71Sopenharmony_ci console.error(`catch error, code: ${(error as BusinessError).code}, message: ${(error as BusinessError).message}`); 1130e41f4b71Sopenharmony_ci} 1131e41f4b71Sopenharmony_ci``` 1132e41f4b71Sopenharmony_ci 1133e41f4b71Sopenharmony_ci## getFormsInfo 1134e41f4b71Sopenharmony_ci 1135e41f4b71Sopenharmony_cigetFormsInfo(bundleName: string, callback: AsyncCallback<Array<formInfo.FormInfo>>): void 1136e41f4b71Sopenharmony_ci 1137e41f4b71Sopenharmony_ci获取设备上指定应用程序提供的卡片信息。使用callback异步回调。 1138e41f4b71Sopenharmony_ci 1139e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 1140e41f4b71Sopenharmony_ci 1141e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Ability.Form 1142e41f4b71Sopenharmony_ci 1143e41f4b71Sopenharmony_ci**参数:** 1144e41f4b71Sopenharmony_ci 1145e41f4b71Sopenharmony_ci| 参数名 | 类型 | 必填 | 说明 | 1146e41f4b71Sopenharmony_ci| ------ |----------------------------------------------------------------------------------------------| ---- | ------- | 1147e41f4b71Sopenharmony_ci| bundleName | string | 是 | 要查询的应用Bundle名称。 | 1148e41f4b71Sopenharmony_ci| callback | AsyncCallback<Array<[formInfo.FormInfo](js-apis-app-form-formInfo.md#forminfo)>> | 是 | 回调函数。当获取设备上指定应用程序提供的卡片信息成功,error为undefined,data为查询到的卡片信息;否则为错误对象。 | 1149e41f4b71Sopenharmony_ci 1150e41f4b71Sopenharmony_ci**错误码:** 1151e41f4b71Sopenharmony_ci 1152e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 | 1153e41f4b71Sopenharmony_ci| -------- | -------- | 1154e41f4b71Sopenharmony_ci| 201 | Permissions denied. | 1155e41f4b71Sopenharmony_ci| 202 | The application is not a system application. | 1156e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. | 1157e41f4b71Sopenharmony_ci| 16500050 | IPC connection error. | 1158e41f4b71Sopenharmony_ci| 16500060 | Service connection error. | 1159e41f4b71Sopenharmony_ci| 16500100 | Failed to obtain the configuration information. | 1160e41f4b71Sopenharmony_ci| 16501000 | An internal functional error occurred. | 1161e41f4b71Sopenharmony_ci 1162e41f4b71Sopenharmony_ci以上错误码的详细介绍请参见[卡片错误码](errorcode-form.md)。 1163e41f4b71Sopenharmony_ci 1164e41f4b71Sopenharmony_ci**示例:** 1165e41f4b71Sopenharmony_ci 1166e41f4b71Sopenharmony_ci```ts 1167e41f4b71Sopenharmony_ciimport { formHost, formInfo } from '@kit.FormKit'; 1168e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 1169e41f4b71Sopenharmony_ci 1170e41f4b71Sopenharmony_citry { 1171e41f4b71Sopenharmony_ci formHost.getFormsInfo('com.example.ohos.formjsdemo', (error: BusinessError, data: formInfo.FormInfo[]) => { 1172e41f4b71Sopenharmony_ci if (error) { 1173e41f4b71Sopenharmony_ci console.error(`error, code: ${error.code}, message: ${error.message}`); 1174e41f4b71Sopenharmony_ci } else { 1175e41f4b71Sopenharmony_ci console.log(`formHost getFormsInfo, data: ${JSON.stringify(data)}`); 1176e41f4b71Sopenharmony_ci } 1177e41f4b71Sopenharmony_ci }); 1178e41f4b71Sopenharmony_ci} catch(error) { 1179e41f4b71Sopenharmony_ci console.error(`catch error, code: ${(error as BusinessError).code}, message: ${(error as BusinessError).message}`); 1180e41f4b71Sopenharmony_ci} 1181e41f4b71Sopenharmony_ci``` 1182e41f4b71Sopenharmony_ci 1183e41f4b71Sopenharmony_ci## getFormsInfo 1184e41f4b71Sopenharmony_ci 1185e41f4b71Sopenharmony_cigetFormsInfo(bundleName: string, moduleName: string, callback: AsyncCallback<Array<formInfo.FormInfo>>): void 1186e41f4b71Sopenharmony_ci 1187e41f4b71Sopenharmony_ci获取设备上指定应用程序提供的卡片信息。使用callback异步回调。 1188e41f4b71Sopenharmony_ci 1189e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 1190e41f4b71Sopenharmony_ci 1191e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Ability.Form 1192e41f4b71Sopenharmony_ci 1193e41f4b71Sopenharmony_ci**参数:** 1194e41f4b71Sopenharmony_ci 1195e41f4b71Sopenharmony_ci| 参数名 | 类型 | 必填 | 说明 | 1196e41f4b71Sopenharmony_ci| ------ |----------------------------------------------------------------------------------------------| ---- | ------- | 1197e41f4b71Sopenharmony_ci| bundleName | string | 是 | 要查询的应用Bundle名称。 | 1198e41f4b71Sopenharmony_ci| moduleName | string | 是 | 要查询的模块名称。 | 1199e41f4b71Sopenharmony_ci| callback | AsyncCallback<Array<[formInfo.FormInfo](js-apis-app-form-formInfo.md#forminfo)>> | 是 | 回调函数。当获取设备上指定应用程序提供的卡片信息成功,error为undefined,data为查询到的卡片信息;否则为错误对象。 | 1200e41f4b71Sopenharmony_ci 1201e41f4b71Sopenharmony_ci**错误码:** 1202e41f4b71Sopenharmony_ci 1203e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 | 1204e41f4b71Sopenharmony_ci| -------- | -------- | 1205e41f4b71Sopenharmony_ci| 201 | Permissions denied. | 1206e41f4b71Sopenharmony_ci| 202 | The application is not a system application. | 1207e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. | 1208e41f4b71Sopenharmony_ci| 16500050 | IPC connection error. | 1209e41f4b71Sopenharmony_ci| 16500060 | Service connection error. | 1210e41f4b71Sopenharmony_ci| 16500100 | Failed to obtain the configuration information. | 1211e41f4b71Sopenharmony_ci| 16501000 | An internal functional error occurred. | 1212e41f4b71Sopenharmony_ci 1213e41f4b71Sopenharmony_ci以上错误码的详细介绍请参见[卡片错误码](errorcode-form.md)。 1214e41f4b71Sopenharmony_ci 1215e41f4b71Sopenharmony_ci**示例:** 1216e41f4b71Sopenharmony_ci 1217e41f4b71Sopenharmony_ci```ts 1218e41f4b71Sopenharmony_ciimport { formHost, formInfo } from '@kit.FormKit'; 1219e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 1220e41f4b71Sopenharmony_ci 1221e41f4b71Sopenharmony_citry { 1222e41f4b71Sopenharmony_ci formHost.getFormsInfo('com.example.ohos.formjsdemo', 'entry', (error: BusinessError, data: formInfo.FormInfo[]) => { 1223e41f4b71Sopenharmony_ci if (error) { 1224e41f4b71Sopenharmony_ci console.error(`error, code: ${error.code}, message: ${error.message}`); 1225e41f4b71Sopenharmony_ci } else { 1226e41f4b71Sopenharmony_ci console.log(`formHost getFormsInfo, data: ${JSON.stringify(data)}`); 1227e41f4b71Sopenharmony_ci } 1228e41f4b71Sopenharmony_ci }); 1229e41f4b71Sopenharmony_ci} catch(error) { 1230e41f4b71Sopenharmony_ci console.error(`catch error, code: ${(error as BusinessError).code}, message: ${(error as BusinessError).message}`); 1231e41f4b71Sopenharmony_ci} 1232e41f4b71Sopenharmony_ci``` 1233e41f4b71Sopenharmony_ci 1234e41f4b71Sopenharmony_ci## getFormsInfo 1235e41f4b71Sopenharmony_ci 1236e41f4b71Sopenharmony_cigetFormsInfo(bundleName: string, moduleName?: string): Promise<Array<formInfo.FormInfo>> 1237e41f4b71Sopenharmony_ci 1238e41f4b71Sopenharmony_ci获取设备上指定应用程序提供的卡片信息。使用Promise异步回调。 1239e41f4b71Sopenharmony_ci 1240e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 1241e41f4b71Sopenharmony_ci 1242e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Ability.Form 1243e41f4b71Sopenharmony_ci 1244e41f4b71Sopenharmony_ci**参数:** 1245e41f4b71Sopenharmony_ci 1246e41f4b71Sopenharmony_ci| 参数名 | 类型 | 必填 | 说明 | 1247e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ------- | 1248e41f4b71Sopenharmony_ci| bundleName | string | 是 | 要查询的应用Bundle名称。 | 1249e41f4b71Sopenharmony_ci| moduleName | string | 否 | 要查询的模块名称,缺省默认为空。 | 1250e41f4b71Sopenharmony_ci 1251e41f4b71Sopenharmony_ci**返回值:** 1252e41f4b71Sopenharmony_ci 1253e41f4b71Sopenharmony_ci| 类型 | 说明 | 1254e41f4b71Sopenharmony_ci|:---------------------------------------------------------------------------------------| :---------------------------------- | 1255e41f4b71Sopenharmony_ci| Promise<Array<[formInfo.FormInfo](js-apis-app-form-formInfo.md#forminfo)>> | Promise对象。返回查询到的卡片信息。 | 1256e41f4b71Sopenharmony_ci 1257e41f4b71Sopenharmony_ci**错误码:** 1258e41f4b71Sopenharmony_ci 1259e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 | 1260e41f4b71Sopenharmony_ci| -------- | -------- | 1261e41f4b71Sopenharmony_ci| 201 | Permissions denied. | 1262e41f4b71Sopenharmony_ci| 202 | The application is not a system application. | 1263e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. | 1264e41f4b71Sopenharmony_ci| 16500050 | IPC connection error. | 1265e41f4b71Sopenharmony_ci| 16500060 | Service connection error. | 1266e41f4b71Sopenharmony_ci| 16500100 | Failed to obtain the configuration information. | 1267e41f4b71Sopenharmony_ci| 16501000 | An internal functional error occurred. | 1268e41f4b71Sopenharmony_ci 1269e41f4b71Sopenharmony_ci以上错误码的详细介绍请参见[卡片错误码](errorcode-form.md)。 1270e41f4b71Sopenharmony_ci 1271e41f4b71Sopenharmony_ci**示例:** 1272e41f4b71Sopenharmony_ci 1273e41f4b71Sopenharmony_ci```ts 1274e41f4b71Sopenharmony_ciimport { formHost, formInfo } from '@kit.FormKit'; 1275e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 1276e41f4b71Sopenharmony_ci 1277e41f4b71Sopenharmony_citry { 1278e41f4b71Sopenharmony_ci formHost.getFormsInfo('com.example.ohos.formjsdemo', 'entry').then((data: formInfo.FormInfo[]) => { 1279e41f4b71Sopenharmony_ci console.log(`formHost getFormsInfo, data: ${JSON.stringify(data)}`); 1280e41f4b71Sopenharmony_ci }).catch((error: BusinessError) => { 1281e41f4b71Sopenharmony_ci console.error(`error, code: ${error.code}, message: ${error.message}`); 1282e41f4b71Sopenharmony_ci }); 1283e41f4b71Sopenharmony_ci} catch(error) { 1284e41f4b71Sopenharmony_ci console.error(`catch error, code: ${(error as BusinessError).code}, message: ${(error as BusinessError).message}`); 1285e41f4b71Sopenharmony_ci} 1286e41f4b71Sopenharmony_ci``` 1287e41f4b71Sopenharmony_ci 1288e41f4b71Sopenharmony_ci## getFormsInfo<sup>12+</sup> 1289e41f4b71Sopenharmony_ci 1290e41f4b71Sopenharmony_cigetFormsInfo(filter: formInfo.FormInfoFilter): Promise<Array<formInfo.FormInfo>> 1291e41f4b71Sopenharmony_ci 1292e41f4b71Sopenharmony_ci获取设备上指定应用程序提供的卡片信息。使用Promise异步回调。 1293e41f4b71Sopenharmony_ci 1294e41f4b71Sopenharmony_ci**需要权限**:ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 1295e41f4b71Sopenharmony_ci 1296e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Ability.Form 1297e41f4b71Sopenharmony_ci 1298e41f4b71Sopenharmony_ci**参数:** 1299e41f4b71Sopenharmony_ci 1300e41f4b71Sopenharmony_ci| 参数名 | 类型 | 必填 | 说明 | 1301e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ------- | 1302e41f4b71Sopenharmony_ci| filter | [formInfo.FormInfoFilter](js-apis-app-form-formInfo.md#forminfofilter) | 是 | 卡片信息过滤器。 | 1303e41f4b71Sopenharmony_ci 1304e41f4b71Sopenharmony_ci**返回值:** 1305e41f4b71Sopenharmony_ci 1306e41f4b71Sopenharmony_ci| 类型 | 说明 | 1307e41f4b71Sopenharmony_ci| :------------ | :---------------------------------- | 1308e41f4b71Sopenharmony_ci| Promise<Array<[formInfo.FormInfo](js-apis-app-form-formInfo.md)>> | Promise对象。返回查询到符合条件的卡片信息。 | 1309e41f4b71Sopenharmony_ci 1310e41f4b71Sopenharmony_ci**错误码:** 1311e41f4b71Sopenharmony_ci 1312e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 | 1313e41f4b71Sopenharmony_ci| -------- | -------- | 1314e41f4b71Sopenharmony_ci| 201 | Permissions denied. | 1315e41f4b71Sopenharmony_ci| 202 | The application is not a system application. | 1316e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. | 1317e41f4b71Sopenharmony_ci| 16500050 | IPC connection error. | 1318e41f4b71Sopenharmony_ci| 16500060 | Service connection error. | 1319e41f4b71Sopenharmony_ci| 16500100 | Failed to obtain the configuration information. | 1320e41f4b71Sopenharmony_ci| 16501000 | An internal functional error occurred. | 1321e41f4b71Sopenharmony_ci 1322e41f4b71Sopenharmony_ci以上错误码的详细介绍请参见[卡片错误码](errorcode-form.md)。 1323e41f4b71Sopenharmony_ci 1324e41f4b71Sopenharmony_ci**示例:** 1325e41f4b71Sopenharmony_ci 1326e41f4b71Sopenharmony_ci```ts 1327e41f4b71Sopenharmony_ciimport { formHost, formInfo } from '@kit.FormKit'; 1328e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 1329e41f4b71Sopenharmony_ci 1330e41f4b71Sopenharmony_ciconst filter: formInfo.FormInfoFilter = { 1331e41f4b71Sopenharmony_ci bundleName: 'ohos.samples.FormApplication', 1332e41f4b71Sopenharmony_ci moduleName: 'entry', 1333e41f4b71Sopenharmony_ci supportedDimensions: [FormDimension.Dimension_1_2, FormDimension.Dimension_2_2, FormDimension.Dimension_2_4] 1334e41f4b71Sopenharmony_ci}; 1335e41f4b71Sopenharmony_citry { 1336e41f4b71Sopenharmony_ci formHost.getFormsInfo(filter).then((data: formInfo.FormInfo[]) => { 1337e41f4b71Sopenharmony_ci console.log(`formHost getFormsInfo, data: ${JSON.stringify(data)}`); 1338e41f4b71Sopenharmony_ci }).catch((error: BusinessError) => { 1339e41f4b71Sopenharmony_ci console.error(`promise error, code: ${error.code}, message: ${error.message})`); 1340e41f4b71Sopenharmony_ci }); 1341e41f4b71Sopenharmony_ci} catch (error) { 1342e41f4b71Sopenharmony_ci console.error(`catch error, code: ${(error as BusinessError).code}, message: ${(error as BusinessError).message})`); 1343e41f4b71Sopenharmony_ci} 1344e41f4b71Sopenharmony_ci``` 1345e41f4b71Sopenharmony_ci 1346e41f4b71Sopenharmony_ci## deleteInvalidForms 1347e41f4b71Sopenharmony_ci 1348e41f4b71Sopenharmony_cideleteInvalidForms(formIds: Array<string>, callback: AsyncCallback<number>): void 1349e41f4b71Sopenharmony_ci 1350e41f4b71Sopenharmony_ci根据列表删除应用程序的无效卡片。使用callback异步回调。 1351e41f4b71Sopenharmony_ci 1352e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.REQUIRE_FORM 1353e41f4b71Sopenharmony_ci 1354e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Ability.Form 1355e41f4b71Sopenharmony_ci 1356e41f4b71Sopenharmony_ci**参数:** 1357e41f4b71Sopenharmony_ci 1358e41f4b71Sopenharmony_ci| 参数名 | 类型 | 必填 | 说明 | 1359e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ------- | 1360e41f4b71Sopenharmony_ci| formIds | Array<string> | 是 | 有效卡片标识列表。 | 1361e41f4b71Sopenharmony_ci| callback | AsyncCallback<number> | 是 | 回调函数。当根据列表删除应用程序的无效卡片成功,error为undefined,data为删除的卡片个数;否则为错误对象。 | 1362e41f4b71Sopenharmony_ci 1363e41f4b71Sopenharmony_ci**错误码:** 1364e41f4b71Sopenharmony_ci 1365e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 | 1366e41f4b71Sopenharmony_ci| -------- | -------- | 1367e41f4b71Sopenharmony_ci| 201 | Permissions denied. | 1368e41f4b71Sopenharmony_ci| 202 | The application is not a system application. | 1369e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. | 1370e41f4b71Sopenharmony_ci| 16500050 | IPC connection error. | 1371e41f4b71Sopenharmony_ci| 16500060 | Service connection error. | 1372e41f4b71Sopenharmony_ci| 16501000 | An internal functional error occurred. | 1373e41f4b71Sopenharmony_ci 1374e41f4b71Sopenharmony_ci以上错误码的详细介绍请参见[卡片错误码](errorcode-form.md)。 1375e41f4b71Sopenharmony_ci 1376e41f4b71Sopenharmony_ci**示例:** 1377e41f4b71Sopenharmony_ci 1378e41f4b71Sopenharmony_ci```ts 1379e41f4b71Sopenharmony_ciimport { formHost } from '@kit.FormKit'; 1380e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 1381e41f4b71Sopenharmony_ci 1382e41f4b71Sopenharmony_citry { 1383e41f4b71Sopenharmony_ci let formIds: string[] = new Array('12400633174999288', '12400633174999289'); 1384e41f4b71Sopenharmony_ci formHost.deleteInvalidForms(formIds, (error: BusinessError, data: number) => { 1385e41f4b71Sopenharmony_ci if (error) { 1386e41f4b71Sopenharmony_ci console.error(`error, code: ${error.code}, message: ${error.message}`); 1387e41f4b71Sopenharmony_ci } else { 1388e41f4b71Sopenharmony_ci console.log(`formHost deleteInvalidForms, data: ${JSON.stringify(data)}`); 1389e41f4b71Sopenharmony_ci } 1390e41f4b71Sopenharmony_ci }); 1391e41f4b71Sopenharmony_ci} catch(error) { 1392e41f4b71Sopenharmony_ci console.error(`catch error, code: ${(error as BusinessError).code}, message: ${(error as BusinessError).message}`); 1393e41f4b71Sopenharmony_ci} 1394e41f4b71Sopenharmony_ci``` 1395e41f4b71Sopenharmony_ci 1396e41f4b71Sopenharmony_ci## deleteInvalidForms 1397e41f4b71Sopenharmony_ci 1398e41f4b71Sopenharmony_cideleteInvalidForms(formIds: Array<string>): Promise<number> 1399e41f4b71Sopenharmony_ci 1400e41f4b71Sopenharmony_ci根据列表删除应用程序的无效卡片。使用Promise异步回调。 1401e41f4b71Sopenharmony_ci 1402e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.REQUIRE_FORM 1403e41f4b71Sopenharmony_ci 1404e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Ability.Form 1405e41f4b71Sopenharmony_ci 1406e41f4b71Sopenharmony_ci**参数:** 1407e41f4b71Sopenharmony_ci 1408e41f4b71Sopenharmony_ci| 参数名 | 类型 | 必填 | 说明 | 1409e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ------- | 1410e41f4b71Sopenharmony_ci| formIds | Array<string> | 是 | 有效卡片标识列表。 | 1411e41f4b71Sopenharmony_ci 1412e41f4b71Sopenharmony_ci**返回值:** 1413e41f4b71Sopenharmony_ci 1414e41f4b71Sopenharmony_ci| 类型 | 说明 | 1415e41f4b71Sopenharmony_ci| :------------ | :---------------------------------- | 1416e41f4b71Sopenharmony_ci| Promise<number> | Promise对象。返回删除的卡片个数。 | 1417e41f4b71Sopenharmony_ci 1418e41f4b71Sopenharmony_ci**错误码:** 1419e41f4b71Sopenharmony_ci 1420e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 | 1421e41f4b71Sopenharmony_ci| -------- | -------- | 1422e41f4b71Sopenharmony_ci| 201 | Permissions denied. | 1423e41f4b71Sopenharmony_ci| 202 | The application is not a system application. | 1424e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. | 1425e41f4b71Sopenharmony_ci| 16500050 | IPC connection error. | 1426e41f4b71Sopenharmony_ci| 16500060 | Service connection error. | 1427e41f4b71Sopenharmony_ci| 16501000 | An internal functional error occurred. | 1428e41f4b71Sopenharmony_ci 1429e41f4b71Sopenharmony_ci以上错误码的详细介绍请参见[卡片错误码](errorcode-form.md)。 1430e41f4b71Sopenharmony_ci 1431e41f4b71Sopenharmony_ci**示例:** 1432e41f4b71Sopenharmony_ci 1433e41f4b71Sopenharmony_ci```ts 1434e41f4b71Sopenharmony_ciimport { formHost } from '@kit.FormKit'; 1435e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 1436e41f4b71Sopenharmony_ci 1437e41f4b71Sopenharmony_citry { 1438e41f4b71Sopenharmony_ci let formIds: string[] = new Array('12400633174999288', '12400633174999289'); 1439e41f4b71Sopenharmony_ci formHost.deleteInvalidForms(formIds).then((data: number) => { 1440e41f4b71Sopenharmony_ci console.log(`formHost deleteInvalidForms, data: ${JSON.stringify(data)}`); 1441e41f4b71Sopenharmony_ci }).catch((error: BusinessError) => { 1442e41f4b71Sopenharmony_ci console.error(`error, code: ${error.code}, message: ${error.message}`); 1443e41f4b71Sopenharmony_ci }); 1444e41f4b71Sopenharmony_ci} catch(error) { 1445e41f4b71Sopenharmony_ci console.error(`catch error, code: ${(error as BusinessError).code}, message: ${(error as BusinessError).message}`); 1446e41f4b71Sopenharmony_ci} 1447e41f4b71Sopenharmony_ci``` 1448e41f4b71Sopenharmony_ci 1449e41f4b71Sopenharmony_ci## acquireFormState 1450e41f4b71Sopenharmony_ci 1451e41f4b71Sopenharmony_ciacquireFormState(want: Want, callback: AsyncCallback<formInfo.FormStateInfo>): void 1452e41f4b71Sopenharmony_ci 1453e41f4b71Sopenharmony_ci获取卡片状态。使用callback异步回调。 1454e41f4b71Sopenharmony_ci 1455e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.REQUIRE_FORM 和 ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 1456e41f4b71Sopenharmony_ci 1457e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Ability.Form 1458e41f4b71Sopenharmony_ci 1459e41f4b71Sopenharmony_ci**参数:** 1460e41f4b71Sopenharmony_ci 1461e41f4b71Sopenharmony_ci| 参数名 | 类型 | 必填 | 说明 | 1462e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ------- | 1463e41f4b71Sopenharmony_ci| want | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | 是 | 查询卡片状态时携带的want信息。需要包含bundle名、ability名、module名、卡片名、卡片规格等。 | 1464e41f4b71Sopenharmony_ci| callback | AsyncCallback<[formInfo.FormStateInfo](js-apis-app-form-formInfo.md#formstateinfo)> | 是 | 回调函数。当获取卡片状态成功,error为undefined,data为获取到的卡片状态;否则为错误对象。 | 1465e41f4b71Sopenharmony_ci 1466e41f4b71Sopenharmony_ci**错误码:** 1467e41f4b71Sopenharmony_ci 1468e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 | 1469e41f4b71Sopenharmony_ci| -------- | -------- | 1470e41f4b71Sopenharmony_ci| 201 | Permissions denied. | 1471e41f4b71Sopenharmony_ci| 202 | The application is not a system application. | 1472e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. | 1473e41f4b71Sopenharmony_ci| 16500050 | IPC connection error. | 1474e41f4b71Sopenharmony_ci| 16500060 | Service connection error. | 1475e41f4b71Sopenharmony_ci| 16500100 | Failed to obtain the configuration information. | 1476e41f4b71Sopenharmony_ci| 16501000 | An internal functional error occurred. | 1477e41f4b71Sopenharmony_ci 1478e41f4b71Sopenharmony_ci以上错误码的详细介绍请参见[卡片错误码](errorcode-form.md)。 1479e41f4b71Sopenharmony_ci 1480e41f4b71Sopenharmony_ci**示例:** 1481e41f4b71Sopenharmony_ci 1482e41f4b71Sopenharmony_ci```ts 1483e41f4b71Sopenharmony_ciimport { formHost, formInfo } from '@kit.FormKit'; 1484e41f4b71Sopenharmony_ciimport { Want } from '@kit.AbilityKit'; 1485e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 1486e41f4b71Sopenharmony_ci 1487e41f4b71Sopenharmony_cilet want: Want = { 1488e41f4b71Sopenharmony_ci 'deviceId': '', 1489e41f4b71Sopenharmony_ci 'bundleName': 'ohos.samples.FormApplication', 1490e41f4b71Sopenharmony_ci 'abilityName': 'FormAbility', 1491e41f4b71Sopenharmony_ci 'parameters': { 1492e41f4b71Sopenharmony_ci 'ohos.extra.param.key.module_name': 'entry', 1493e41f4b71Sopenharmony_ci 'ohos.extra.param.key.form_name': 'widget', 1494e41f4b71Sopenharmony_ci 'ohos.extra.param.key.form_dimension': 2 1495e41f4b71Sopenharmony_ci } 1496e41f4b71Sopenharmony_ci}; 1497e41f4b71Sopenharmony_citry { 1498e41f4b71Sopenharmony_ci formHost.acquireFormState(want, (error: BusinessError, data: formInfo.FormStateInfo) => { 1499e41f4b71Sopenharmony_ci if (error) { 1500e41f4b71Sopenharmony_ci console.error(`error, code: ${error.code}, message: ${error.message}`); 1501e41f4b71Sopenharmony_ci } else { 1502e41f4b71Sopenharmony_ci console.log(`formHost acquireFormState, data: ${JSON.stringify(data)}`); 1503e41f4b71Sopenharmony_ci } 1504e41f4b71Sopenharmony_ci }); 1505e41f4b71Sopenharmony_ci} catch (error) { 1506e41f4b71Sopenharmony_ci console.error(`catch error, code: ${(error as BusinessError).code}, message: ${(error as BusinessError).message}`); 1507e41f4b71Sopenharmony_ci} 1508e41f4b71Sopenharmony_ci``` 1509e41f4b71Sopenharmony_ci 1510e41f4b71Sopenharmony_ci## acquireFormState 1511e41f4b71Sopenharmony_ci 1512e41f4b71Sopenharmony_ciacquireFormState(want: Want): Promise<formInfo.FormStateInfo> 1513e41f4b71Sopenharmony_ci 1514e41f4b71Sopenharmony_ci获取卡片状态。使用Promise异步回调。 1515e41f4b71Sopenharmony_ci 1516e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.REQUIRE_FORM 和 ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 1517e41f4b71Sopenharmony_ci 1518e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Ability.Form 1519e41f4b71Sopenharmony_ci 1520e41f4b71Sopenharmony_ci**参数:** 1521e41f4b71Sopenharmony_ci 1522e41f4b71Sopenharmony_ci| 参数名 | 类型 | 必填 | 说明 | 1523e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ------- | 1524e41f4b71Sopenharmony_ci| want | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | 是 | 查询卡片状态时携带的want信息。需要包含bundle名、ability名、module名、卡片名、卡片规格等。 | 1525e41f4b71Sopenharmony_ci 1526e41f4b71Sopenharmony_ci**返回值:** 1527e41f4b71Sopenharmony_ci 1528e41f4b71Sopenharmony_ci| 类型 | 说明 | 1529e41f4b71Sopenharmony_ci| :------------ | :---------------------------------- | 1530e41f4b71Sopenharmony_ci| Promise<[formInfo.FormStateInfo](js-apis-app-form-formInfo.md#formstateinfo)> | Promise对象。返回卡片状态。 | 1531e41f4b71Sopenharmony_ci 1532e41f4b71Sopenharmony_ci**错误码:** 1533e41f4b71Sopenharmony_ci 1534e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 | 1535e41f4b71Sopenharmony_ci| -------- | -------- | 1536e41f4b71Sopenharmony_ci| 201 | Permissions denied. | 1537e41f4b71Sopenharmony_ci| 202 | The application is not a system application. | 1538e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. | 1539e41f4b71Sopenharmony_ci| 16500050 | IPC connection error. | 1540e41f4b71Sopenharmony_ci| 16500060 | Service connection error. | 1541e41f4b71Sopenharmony_ci| 16500100 | Failed to obtain the configuration information. | 1542e41f4b71Sopenharmony_ci| 16501000 | An internal functional error occurred. | 1543e41f4b71Sopenharmony_ci 1544e41f4b71Sopenharmony_ci以上错误码的详细介绍请参见[卡片错误码](errorcode-form.md)。 1545e41f4b71Sopenharmony_ci 1546e41f4b71Sopenharmony_ci**示例:** 1547e41f4b71Sopenharmony_ci 1548e41f4b71Sopenharmony_ci```ts 1549e41f4b71Sopenharmony_ciimport { formHost, formInfo } from '@kit.FormKit'; 1550e41f4b71Sopenharmony_ciimport { Want } from '@kit.AbilityKit'; 1551e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 1552e41f4b71Sopenharmony_ci 1553e41f4b71Sopenharmony_cilet want: Want = { 1554e41f4b71Sopenharmony_ci 'deviceId': '', 1555e41f4b71Sopenharmony_ci 'bundleName': 'ohos.samples.FormApplication', 1556e41f4b71Sopenharmony_ci 'abilityName': 'FormAbility', 1557e41f4b71Sopenharmony_ci 'parameters': { 1558e41f4b71Sopenharmony_ci 'ohos.extra.param.key.module_name': 'entry', 1559e41f4b71Sopenharmony_ci 'ohos.extra.param.key.form_name': 'widget', 1560e41f4b71Sopenharmony_ci 'ohos.extra.param.key.form_dimension': 2 1561e41f4b71Sopenharmony_ci } 1562e41f4b71Sopenharmony_ci}; 1563e41f4b71Sopenharmony_citry { 1564e41f4b71Sopenharmony_ci formHost.acquireFormState(want).then((data: formInfo.FormStateInfo) => { 1565e41f4b71Sopenharmony_ci console.log(`formHost acquireFormState, data: ${JSON.stringify(data)}`); 1566e41f4b71Sopenharmony_ci }).catch((error: BusinessError) => { 1567e41f4b71Sopenharmony_ci console.error(`error, code: ${error.code}, message: ${error.message}`); 1568e41f4b71Sopenharmony_ci }); 1569e41f4b71Sopenharmony_ci} catch(error) { 1570e41f4b71Sopenharmony_ci console.error(`catch error, code: ${(error as BusinessError).code}, message: ${(error as BusinessError).message}`); 1571e41f4b71Sopenharmony_ci} 1572e41f4b71Sopenharmony_ci``` 1573e41f4b71Sopenharmony_ci 1574e41f4b71Sopenharmony_ci## on('formUninstall') 1575e41f4b71Sopenharmony_ci 1576e41f4b71Sopenharmony_cion(type: 'formUninstall', callback: Callback<string>): void 1577e41f4b71Sopenharmony_ci 1578e41f4b71Sopenharmony_ci订阅卡片卸载事件。使用callback异步回调。 1579e41f4b71Sopenharmony_ci 1580e41f4b71Sopenharmony_ci> **说明:** 1581e41f4b71Sopenharmony_ci> 1582e41f4b71Sopenharmony_ci> 卡片卸载与卡片移除不同。当应用卸载时,对应的卡片会自动卸载。 1583e41f4b71Sopenharmony_ci 1584e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Ability.Form 1585e41f4b71Sopenharmony_ci 1586e41f4b71Sopenharmony_ci**参数:** 1587e41f4b71Sopenharmony_ci 1588e41f4b71Sopenharmony_ci| 参数名 | 类型 | 必填 | 说明 | 1589e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ------- | 1590e41f4b71Sopenharmony_ci| type | string | 是 | 填写'formUninstall',表示卡片卸载事件。 | 1591e41f4b71Sopenharmony_ci| callback | Callback<string> | 是 | 回调函数,返回卡片标识。 | 1592e41f4b71Sopenharmony_ci 1593e41f4b71Sopenharmony_ci**错误码:** 1594e41f4b71Sopenharmony_ci 1595e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 | 1596e41f4b71Sopenharmony_ci| -------- | -------- | 1597e41f4b71Sopenharmony_ci| 202 | The application is not a system application. | 1598e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. | 1599e41f4b71Sopenharmony_ci 1600e41f4b71Sopenharmony_ci以上错误码的详细介绍请参见[卡片错误码](errorcode-form.md)。 1601e41f4b71Sopenharmony_ci 1602e41f4b71Sopenharmony_ci**示例:** 1603e41f4b71Sopenharmony_ci 1604e41f4b71Sopenharmony_ci```ts 1605e41f4b71Sopenharmony_ciimport { formHost } from '@kit.FormKit'; 1606e41f4b71Sopenharmony_ci 1607e41f4b71Sopenharmony_ciformHost.on('formUninstall', (formId: string) => { 1608e41f4b71Sopenharmony_ci console.log(`formHost on formUninstall, formId: ${formId}`); 1609e41f4b71Sopenharmony_ci}); 1610e41f4b71Sopenharmony_ci``` 1611e41f4b71Sopenharmony_ci 1612e41f4b71Sopenharmony_ci## off('formUninstall') 1613e41f4b71Sopenharmony_ci 1614e41f4b71Sopenharmony_cioff(type: 'formUninstall', callback?: Callback<string>): void 1615e41f4b71Sopenharmony_ci 1616e41f4b71Sopenharmony_ci取消订阅卡片卸载事件。使用callback异步回调。 1617e41f4b71Sopenharmony_ci 1618e41f4b71Sopenharmony_ci> **说明:** 1619e41f4b71Sopenharmony_ci> 1620e41f4b71Sopenharmony_ci> 卡片卸载与卡片移除不同。当应用卸载时,对应的卡片会自动卸载。 1621e41f4b71Sopenharmony_ci 1622e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Ability.Form 1623e41f4b71Sopenharmony_ci 1624e41f4b71Sopenharmony_ci**参数:** 1625e41f4b71Sopenharmony_ci 1626e41f4b71Sopenharmony_ci| 参数名 | 类型 | 必填 | 说明 | 1627e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ------- | 1628e41f4b71Sopenharmony_ci| type | string | 是 | 填写'formUninstall',表示卡片卸载事件。 | 1629e41f4b71Sopenharmony_ci| callback | Callback<string> | 否 | 回调函数,返回卡片标识。缺省时,表示注销所有已注册事件回调。<br> 需与对应on('formUninstall')的callback一致。| 1630e41f4b71Sopenharmony_ci 1631e41f4b71Sopenharmony_ci**错误码:** 1632e41f4b71Sopenharmony_ci 1633e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 | 1634e41f4b71Sopenharmony_ci| -------- | -------- | 1635e41f4b71Sopenharmony_ci| 202 | The application is not a system application. | 1636e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. | 1637e41f4b71Sopenharmony_ci 1638e41f4b71Sopenharmony_ci以上错误码的详细介绍请参见[卡片错误码](errorcode-form.md)。 1639e41f4b71Sopenharmony_ci 1640e41f4b71Sopenharmony_ci**示例:** 1641e41f4b71Sopenharmony_ci 1642e41f4b71Sopenharmony_ci```ts 1643e41f4b71Sopenharmony_ciimport { formHost } from '@kit.FormKit'; 1644e41f4b71Sopenharmony_ci 1645e41f4b71Sopenharmony_ciformHost.off('formUninstall', (formId: string) => { 1646e41f4b71Sopenharmony_ci console.log(`formHost on formUninstall, formId: ${formId}`); 1647e41f4b71Sopenharmony_ci}); 1648e41f4b71Sopenharmony_ci``` 1649e41f4b71Sopenharmony_ci 1650e41f4b71Sopenharmony_ci## notifyFormsVisible 1651e41f4b71Sopenharmony_ci 1652e41f4b71Sopenharmony_cinotifyFormsVisible(formIds: Array<string>, isVisible: boolean, callback: AsyncCallback<void>): void 1653e41f4b71Sopenharmony_ci 1654e41f4b71Sopenharmony_ci通知卡片是否可见。使用callback异步回调。 1655e41f4b71Sopenharmony_ci 1656e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.REQUIRE_FORM 1657e41f4b71Sopenharmony_ci 1658e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Ability.Form 1659e41f4b71Sopenharmony_ci 1660e41f4b71Sopenharmony_ci**参数:** 1661e41f4b71Sopenharmony_ci 1662e41f4b71Sopenharmony_ci| 参数名 | 类型 | 必填 | 说明 | 1663e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ------- | 1664e41f4b71Sopenharmony_ci| formIds | Array<string> | 是 | 卡片标识列表。 | 1665e41f4b71Sopenharmony_ci| isVisible | boolean | 是 | 是否可见。 | 1666e41f4b71Sopenharmony_ci| callback | AsyncCallback<void> | 是 | 回调函数。当通知卡片是否可见成功,error为undefined,否则为错误对象。 | 1667e41f4b71Sopenharmony_ci 1668e41f4b71Sopenharmony_ci**错误码:** 1669e41f4b71Sopenharmony_ci 1670e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 | 1671e41f4b71Sopenharmony_ci| -------- | -------- | 1672e41f4b71Sopenharmony_ci| 201 | Permissions denied. | 1673e41f4b71Sopenharmony_ci| 202 | The application is not a system application. | 1674e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. | 1675e41f4b71Sopenharmony_ci| 16500050 | IPC connection error. | 1676e41f4b71Sopenharmony_ci| 16500060 | Service connection error. | 1677e41f4b71Sopenharmony_ci| 16501000 | An internal functional error occurred. | 1678e41f4b71Sopenharmony_ci| 16501003 | The form cannot be operated by the current application. | 1679e41f4b71Sopenharmony_ci 1680e41f4b71Sopenharmony_ci以上错误码的详细介绍请参见[卡片错误码](errorcode-form.md)。 1681e41f4b71Sopenharmony_ci 1682e41f4b71Sopenharmony_ci**示例:** 1683e41f4b71Sopenharmony_ci 1684e41f4b71Sopenharmony_ci```ts 1685e41f4b71Sopenharmony_ciimport { formHost } from '@kit.FormKit'; 1686e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 1687e41f4b71Sopenharmony_ci 1688e41f4b71Sopenharmony_cilet formIds: string[] = new Array('12400633174999288', '12400633174999289'); 1689e41f4b71Sopenharmony_citry { 1690e41f4b71Sopenharmony_ci formHost.notifyFormsVisible(formIds, true, (error: BusinessError) => { 1691e41f4b71Sopenharmony_ci if (error) { 1692e41f4b71Sopenharmony_ci console.error(`error, code: ${error.code}, message: ${error.message}`); 1693e41f4b71Sopenharmony_ci } 1694e41f4b71Sopenharmony_ci }); 1695e41f4b71Sopenharmony_ci} catch (error) { 1696e41f4b71Sopenharmony_ci console.error(`catch error, code: ${(error as BusinessError).code}, message: ${(error as BusinessError).message}`); 1697e41f4b71Sopenharmony_ci} 1698e41f4b71Sopenharmony_ci``` 1699e41f4b71Sopenharmony_ci 1700e41f4b71Sopenharmony_ci## notifyFormsVisible 1701e41f4b71Sopenharmony_ci 1702e41f4b71Sopenharmony_cinotifyFormsVisible(formIds: Array<string>, isVisible: boolean): Promise<void> 1703e41f4b71Sopenharmony_ci 1704e41f4b71Sopenharmony_ci通知卡片是否可见。使用Promise异步回调。 1705e41f4b71Sopenharmony_ci 1706e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.REQUIRE_FORM 1707e41f4b71Sopenharmony_ci 1708e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Ability.Form 1709e41f4b71Sopenharmony_ci 1710e41f4b71Sopenharmony_ci**参数:** 1711e41f4b71Sopenharmony_ci 1712e41f4b71Sopenharmony_ci| 参数名 | 类型 | 必填 | 说明 | 1713e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ------- | 1714e41f4b71Sopenharmony_ci| formIds | Array<string> | 是 | 卡片标识列表。 | 1715e41f4b71Sopenharmony_ci| isVisible | boolean | 是 | 是否可见。 | 1716e41f4b71Sopenharmony_ci 1717e41f4b71Sopenharmony_ci**返回值:** 1718e41f4b71Sopenharmony_ci 1719e41f4b71Sopenharmony_ci| 类型 | 说明 | 1720e41f4b71Sopenharmony_ci| -------- | -------- | 1721e41f4b71Sopenharmony_ci| Promise<void> | 无返回结果的Promise对象。 | 1722e41f4b71Sopenharmony_ci 1723e41f4b71Sopenharmony_ci**错误码:** 1724e41f4b71Sopenharmony_ci 1725e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 | 1726e41f4b71Sopenharmony_ci| -------- | -------- | 1727e41f4b71Sopenharmony_ci| 201 | Permissions denied. | 1728e41f4b71Sopenharmony_ci| 202 | The application is not a system application. | 1729e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. | 1730e41f4b71Sopenharmony_ci| 16500050 | IPC connection error. | 1731e41f4b71Sopenharmony_ci| 16500060 | Service connection error. | 1732e41f4b71Sopenharmony_ci| 16501000 | An internal functional error occurred. | 1733e41f4b71Sopenharmony_ci| 16501003 | The form cannot be operated by the current application. | 1734e41f4b71Sopenharmony_ci 1735e41f4b71Sopenharmony_ci以上错误码的详细介绍请参见[卡片错误码](errorcode-form.md)。 1736e41f4b71Sopenharmony_ci 1737e41f4b71Sopenharmony_ci**示例:** 1738e41f4b71Sopenharmony_ci 1739e41f4b71Sopenharmony_ci```ts 1740e41f4b71Sopenharmony_ciimport { formHost } from '@kit.FormKit'; 1741e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 1742e41f4b71Sopenharmony_ci 1743e41f4b71Sopenharmony_cilet formIds: string[] = new Array('12400633174999288', '12400633174999289'); 1744e41f4b71Sopenharmony_citry { 1745e41f4b71Sopenharmony_ci formHost.notifyFormsVisible(formIds, true).then(() => { 1746e41f4b71Sopenharmony_ci console.log('formHost notifyFormsVisible success'); 1747e41f4b71Sopenharmony_ci }).catch((error: BusinessError) => { 1748e41f4b71Sopenharmony_ci console.error(`error, code: ${error.code}, message: ${error.message}`); 1749e41f4b71Sopenharmony_ci }); 1750e41f4b71Sopenharmony_ci} catch(error) { 1751e41f4b71Sopenharmony_ci console.error(`catch error, code: ${(error as BusinessError).code}, message: ${(error as BusinessError).message}`); 1752e41f4b71Sopenharmony_ci} 1753e41f4b71Sopenharmony_ci``` 1754e41f4b71Sopenharmony_ci 1755e41f4b71Sopenharmony_ci## notifyFormsEnableUpdate 1756e41f4b71Sopenharmony_ci 1757e41f4b71Sopenharmony_cinotifyFormsEnableUpdate(formIds: Array<string>, isEnableUpdate: boolean, callback: AsyncCallback<void>): void 1758e41f4b71Sopenharmony_ci 1759e41f4b71Sopenharmony_ci通知卡片是否启用更新状态。使用callback异步回调。 1760e41f4b71Sopenharmony_ci 1761e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.REQUIRE_FORM 1762e41f4b71Sopenharmony_ci 1763e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Ability.Form 1764e41f4b71Sopenharmony_ci 1765e41f4b71Sopenharmony_ci**参数:** 1766e41f4b71Sopenharmony_ci 1767e41f4b71Sopenharmony_ci| 参数名 | 类型 | 必填 | 说明 | 1768e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ------- | 1769e41f4b71Sopenharmony_ci| formIds | Array<string> | 是 | 卡片标识列表。 | 1770e41f4b71Sopenharmony_ci| isEnableUpdate | boolean | 是 | 是否使能更新。 | 1771e41f4b71Sopenharmony_ci| callback | AsyncCallback<void> | 是 | 回调函数。当通知卡片是否启用更新状态成功,error为undefined,否则为错误对象。 | 1772e41f4b71Sopenharmony_ci 1773e41f4b71Sopenharmony_ci**错误码:** 1774e41f4b71Sopenharmony_ci 1775e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 | 1776e41f4b71Sopenharmony_ci| -------- | -------- | 1777e41f4b71Sopenharmony_ci| 201 | Permissions denied. | 1778e41f4b71Sopenharmony_ci| 202 | The application is not a system application. | 1779e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. | 1780e41f4b71Sopenharmony_ci| 16500050 | IPC connection error. | 1781e41f4b71Sopenharmony_ci| 16500060 | Service connection error. | 1782e41f4b71Sopenharmony_ci| 16501000 | An internal functional error occurred. | 1783e41f4b71Sopenharmony_ci| 16501003 | The form cannot be operated by the current application. | 1784e41f4b71Sopenharmony_ci 1785e41f4b71Sopenharmony_ci以上错误码的详细介绍请参见[卡片错误码](errorcode-form.md)。 1786e41f4b71Sopenharmony_ci 1787e41f4b71Sopenharmony_ci**示例:** 1788e41f4b71Sopenharmony_ci 1789e41f4b71Sopenharmony_ci```ts 1790e41f4b71Sopenharmony_ciimport { formHost } from '@kit.FormKit'; 1791e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 1792e41f4b71Sopenharmony_ci 1793e41f4b71Sopenharmony_cilet formIds: string[] = new Array('12400633174999288', '12400633174999289'); 1794e41f4b71Sopenharmony_citry { 1795e41f4b71Sopenharmony_ci formHost.notifyFormsEnableUpdate(formIds, true, (error: BusinessError) => { 1796e41f4b71Sopenharmony_ci if (error) { 1797e41f4b71Sopenharmony_ci console.error(`error, code: ${error.code}, message: ${error.message}`); 1798e41f4b71Sopenharmony_ci } 1799e41f4b71Sopenharmony_ci }); 1800e41f4b71Sopenharmony_ci} catch(error) { 1801e41f4b71Sopenharmony_ci console.error(`catch error, code: ${(error as BusinessError).code}, message: ${(error as BusinessError).message}`); 1802e41f4b71Sopenharmony_ci} 1803e41f4b71Sopenharmony_ci``` 1804e41f4b71Sopenharmony_ci 1805e41f4b71Sopenharmony_ci## notifyFormsEnableUpdate 1806e41f4b71Sopenharmony_ci 1807e41f4b71Sopenharmony_cinotifyFormsEnableUpdate(formIds: Array<string>, isEnableUpdate: boolean): Promise<void> 1808e41f4b71Sopenharmony_ci 1809e41f4b71Sopenharmony_ci通知卡片是否启用更新状态。使用Promise异步回调。 1810e41f4b71Sopenharmony_ci 1811e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.REQUIRE_FORM 1812e41f4b71Sopenharmony_ci 1813e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Ability.Form 1814e41f4b71Sopenharmony_ci 1815e41f4b71Sopenharmony_ci**参数:** 1816e41f4b71Sopenharmony_ci 1817e41f4b71Sopenharmony_ci| 参数名 | 类型 | 必填 | 说明 | 1818e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ------- | 1819e41f4b71Sopenharmony_ci| formIds | Array<string> | 是 | 卡片标识列表。 | 1820e41f4b71Sopenharmony_ci| isEnableUpdate | boolean | 是 | 是否使能更新。 | 1821e41f4b71Sopenharmony_ci 1822e41f4b71Sopenharmony_ci**返回值:** 1823e41f4b71Sopenharmony_ci 1824e41f4b71Sopenharmony_ci| 类型 | 说明 | 1825e41f4b71Sopenharmony_ci| -------- | -------- | 1826e41f4b71Sopenharmony_ci| Promise<void> | 无返回结果的Promise对象。 | 1827e41f4b71Sopenharmony_ci 1828e41f4b71Sopenharmony_ci**错误码:** 1829e41f4b71Sopenharmony_ci 1830e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 | 1831e41f4b71Sopenharmony_ci| -------- | -------- | 1832e41f4b71Sopenharmony_ci| 201 | Permissions denied. | 1833e41f4b71Sopenharmony_ci| 202 | The application is not a system application. | 1834e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. | 1835e41f4b71Sopenharmony_ci| 16500050 | IPC connection error. | 1836e41f4b71Sopenharmony_ci| 16500060 | Service connection error. | 1837e41f4b71Sopenharmony_ci| 16501000 | An internal functional error occurred. | 1838e41f4b71Sopenharmony_ci| 16501003 | The form cannot be operated by the current application. | 1839e41f4b71Sopenharmony_ci 1840e41f4b71Sopenharmony_ci以上错误码的详细介绍请参见[卡片错误码](errorcode-form.md)。 1841e41f4b71Sopenharmony_ci 1842e41f4b71Sopenharmony_ci**示例:** 1843e41f4b71Sopenharmony_ci 1844e41f4b71Sopenharmony_ci```ts 1845e41f4b71Sopenharmony_ciimport { formHost } from '@kit.FormKit'; 1846e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 1847e41f4b71Sopenharmony_ci 1848e41f4b71Sopenharmony_cilet formIds: string[] = new Array('12400633174999288', '12400633174999289'); 1849e41f4b71Sopenharmony_citry { 1850e41f4b71Sopenharmony_ci formHost.notifyFormsEnableUpdate(formIds, true).then(() => { 1851e41f4b71Sopenharmony_ci console.log('formHost notifyFormsEnableUpdate success'); 1852e41f4b71Sopenharmony_ci }).catch((error: BusinessError) => { 1853e41f4b71Sopenharmony_ci console.error(`error, code: ${error.code}, message: ${error.message}`); 1854e41f4b71Sopenharmony_ci }); 1855e41f4b71Sopenharmony_ci} catch(error) { 1856e41f4b71Sopenharmony_ci console.error(`catch error, code: ${(error as BusinessError).code}, message: ${(error as BusinessError).message}`); 1857e41f4b71Sopenharmony_ci} 1858e41f4b71Sopenharmony_ci``` 1859e41f4b71Sopenharmony_ci## shareForm 1860e41f4b71Sopenharmony_ci 1861e41f4b71Sopenharmony_cishareForm(formId: string, deviceId: string, callback: AsyncCallback<void>): void 1862e41f4b71Sopenharmony_ci 1863e41f4b71Sopenharmony_ci指定formId和远程设备Id进行卡片分享。使用callback异步回调。 1864e41f4b71Sopenharmony_ci 1865e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.REQUIRE_FORM 和 ohos.permission.DISTRIBUTED_DATASYNC 1866e41f4b71Sopenharmony_ci 1867e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Ability.Form 1868e41f4b71Sopenharmony_ci 1869e41f4b71Sopenharmony_ci**参数:** 1870e41f4b71Sopenharmony_ci 1871e41f4b71Sopenharmony_ci| 参数名 | 类型 | 必填 | 说明 | 1872e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ------- | 1873e41f4b71Sopenharmony_ci| formId | string | 是 | 卡片标识。 | 1874e41f4b71Sopenharmony_ci| deviceId | string | 是 | 远程设备标识。 | 1875e41f4b71Sopenharmony_ci| callback | AsyncCallback<void> | 是 | 回调函数。当指定formId和远程设备Id进行卡片分享成功,error为undefined,否则为错误对象。 | 1876e41f4b71Sopenharmony_ci 1877e41f4b71Sopenharmony_ci**错误码:** 1878e41f4b71Sopenharmony_ci 1879e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 | 1880e41f4b71Sopenharmony_ci| -------- | -------- | 1881e41f4b71Sopenharmony_ci| 201 | Permissions denied. | 1882e41f4b71Sopenharmony_ci| 202 | The application is not a system application. | 1883e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. | 1884e41f4b71Sopenharmony_ci| 16500050 | IPC connection error. | 1885e41f4b71Sopenharmony_ci| 16501000 | An internal functional error occurred. | 1886e41f4b71Sopenharmony_ci| 16501001 | The ID of the form to be operated does not exist. | 1887e41f4b71Sopenharmony_ci| 16501003 | The form cannot be operated by the current application. | 1888e41f4b71Sopenharmony_ci 1889e41f4b71Sopenharmony_ci以上错误码的详细介绍请参见[卡片错误码](errorcode-form.md)。 1890e41f4b71Sopenharmony_ci 1891e41f4b71Sopenharmony_ci**示例:** 1892e41f4b71Sopenharmony_ci 1893e41f4b71Sopenharmony_ci```ts 1894e41f4b71Sopenharmony_ciimport { formHost } from '@kit.FormKit'; 1895e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 1896e41f4b71Sopenharmony_ci 1897e41f4b71Sopenharmony_cilet formId: string = '12400633174999288'; 1898e41f4b71Sopenharmony_cilet deviceId: string = 'EFC11C0C53628D8CC2F8CB5052477E130D075917034613B9884C55CD22B3DEF2'; 1899e41f4b71Sopenharmony_citry { 1900e41f4b71Sopenharmony_ci formHost.shareForm(formId, deviceId, (error: BusinessError) => { 1901e41f4b71Sopenharmony_ci if (error) { 1902e41f4b71Sopenharmony_ci console.error(`error, code: ${error.code}, message: ${error.message}`); 1903e41f4b71Sopenharmony_ci } 1904e41f4b71Sopenharmony_ci }); 1905e41f4b71Sopenharmony_ci} catch(error) { 1906e41f4b71Sopenharmony_ci console.error(`catch error, code: ${(error as BusinessError).code}, message: ${(error as BusinessError).message}`); 1907e41f4b71Sopenharmony_ci} 1908e41f4b71Sopenharmony_ci``` 1909e41f4b71Sopenharmony_ci 1910e41f4b71Sopenharmony_ci## shareForm 1911e41f4b71Sopenharmony_ci 1912e41f4b71Sopenharmony_cishareForm(formId: string, deviceId: string): Promise<void> 1913e41f4b71Sopenharmony_ci 1914e41f4b71Sopenharmony_ci指定formId和远程设备Id进行卡片分享。使用Promise异步回调。 1915e41f4b71Sopenharmony_ci 1916e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.REQUIRE_FORM 和 ohos.permission.DISTRIBUTED_DATASYNC 1917e41f4b71Sopenharmony_ci 1918e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Ability.Form 1919e41f4b71Sopenharmony_ci 1920e41f4b71Sopenharmony_ci**参数:** 1921e41f4b71Sopenharmony_ci 1922e41f4b71Sopenharmony_ci| 参数名 | 类型 | 必填 | 说明 | 1923e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ------- | 1924e41f4b71Sopenharmony_ci| formId | string | 是 | 卡片标识。 | 1925e41f4b71Sopenharmony_ci| deviceId | string | 是 | 远程设备标识。 | 1926e41f4b71Sopenharmony_ci 1927e41f4b71Sopenharmony_ci**返回值:** 1928e41f4b71Sopenharmony_ci 1929e41f4b71Sopenharmony_ci| 类型 | 说明 | 1930e41f4b71Sopenharmony_ci| -------- | -------- | 1931e41f4b71Sopenharmony_ci| Promise<void> | 无返回结果的Promise对象。 | 1932e41f4b71Sopenharmony_ci 1933e41f4b71Sopenharmony_ci**错误码:** 1934e41f4b71Sopenharmony_ci 1935e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 | 1936e41f4b71Sopenharmony_ci| -------- | -------- | 1937e41f4b71Sopenharmony_ci| 201 | Permissions denied. | 1938e41f4b71Sopenharmony_ci| 202 | The application is not a system application. | 1939e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. | 1940e41f4b71Sopenharmony_ci| 16500050 | IPC connection error. | 1941e41f4b71Sopenharmony_ci| 16501000 | An internal functional error occurred. | 1942e41f4b71Sopenharmony_ci| 16501001 | The ID of the form to be operated does not exist. | 1943e41f4b71Sopenharmony_ci| 16501003 | The form cannot be operated by the current application. | 1944e41f4b71Sopenharmony_ci 1945e41f4b71Sopenharmony_ci以上错误码的详细介绍请参见[卡片错误码](errorcode-form.md)。 1946e41f4b71Sopenharmony_ci 1947e41f4b71Sopenharmony_ci**示例:** 1948e41f4b71Sopenharmony_ci 1949e41f4b71Sopenharmony_ci```ts 1950e41f4b71Sopenharmony_ciimport { formHost } from '@kit.FormKit'; 1951e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 1952e41f4b71Sopenharmony_ci 1953e41f4b71Sopenharmony_cilet formId: string = '12400633174999288'; 1954e41f4b71Sopenharmony_cilet deviceId: string = 'EFC11C0C53628D8CC2F8CB5052477E130D075917034613B9884C55CD22B3DEF2'; 1955e41f4b71Sopenharmony_citry { 1956e41f4b71Sopenharmony_ci formHost.shareForm(formId, deviceId).then(() => { 1957e41f4b71Sopenharmony_ci console.log('formHost shareForm success'); 1958e41f4b71Sopenharmony_ci }).catch((error: BusinessError) => { 1959e41f4b71Sopenharmony_ci console.error(`error, code: ${error.code}, message: ${error.message}`); 1960e41f4b71Sopenharmony_ci }); 1961e41f4b71Sopenharmony_ci} catch(error) { 1962e41f4b71Sopenharmony_ci console.error(`catch error, code: ${(error as BusinessError).code}, message: ${(error as BusinessError).message}`); 1963e41f4b71Sopenharmony_ci} 1964e41f4b71Sopenharmony_ci``` 1965e41f4b71Sopenharmony_ci 1966e41f4b71Sopenharmony_ci## notifyFormsPrivacyProtected 1967e41f4b71Sopenharmony_ci 1968e41f4b71Sopenharmony_cinotifyFormsPrivacyProtected(formIds: Array\<string>, isProtected: boolean, callback: AsyncCallback\<void>): void 1969e41f4b71Sopenharmony_ci 1970e41f4b71Sopenharmony_ci通知指定卡片隐私保护状态改变。使用callback异步回调。 1971e41f4b71Sopenharmony_ci 1972e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.REQUIRE_FORM 1973e41f4b71Sopenharmony_ci 1974e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Ability.Form 1975e41f4b71Sopenharmony_ci 1976e41f4b71Sopenharmony_ci**参数:** 1977e41f4b71Sopenharmony_ci 1978e41f4b71Sopenharmony_ci| 参数名 | 类型 | 必填 | 说明 | 1979e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ------- | 1980e41f4b71Sopenharmony_ci| formIds | Array\<string\> | 是 | 需要修改隐私保护的卡片标识列表。 | 1981e41f4b71Sopenharmony_ci| isProtected | boolean | 是 | 是否进行隐私保护。 | 1982e41f4b71Sopenharmony_ci| callback | AsyncCallback\<void> | 是 | 回调函数。当指定卡片设置隐私保护属性成功,error为undefined,否则为错误对象。 | 1983e41f4b71Sopenharmony_ci 1984e41f4b71Sopenharmony_ci**错误码:** 1985e41f4b71Sopenharmony_ci 1986e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 | 1987e41f4b71Sopenharmony_ci| -------- | -------- | 1988e41f4b71Sopenharmony_ci| 201 | Permissions denied. | 1989e41f4b71Sopenharmony_ci| 202 | The application is not a system application. | 1990e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. | 1991e41f4b71Sopenharmony_ci| 16500050 | IPC connection error. | 1992e41f4b71Sopenharmony_ci| 16500060 | Service connection error. | 1993e41f4b71Sopenharmony_ci| 16501000 | An internal functional error occurred. | 1994e41f4b71Sopenharmony_ci 1995e41f4b71Sopenharmony_ci以上错误码的详细介绍请参见[卡片错误码](errorcode-form.md)。 1996e41f4b71Sopenharmony_ci 1997e41f4b71Sopenharmony_ci**示例:** 1998e41f4b71Sopenharmony_ci 1999e41f4b71Sopenharmony_ci```ts 2000e41f4b71Sopenharmony_ciimport { formHost } from '@kit.FormKit'; 2001e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 2002e41f4b71Sopenharmony_ci 2003e41f4b71Sopenharmony_cilet formIds: string[] = new Array('12400633174999288', '12400633174999289'); 2004e41f4b71Sopenharmony_citry { 2005e41f4b71Sopenharmony_ci formHost.notifyFormsPrivacyProtected(formIds, true, (error: BusinessError) => { 2006e41f4b71Sopenharmony_ci if (error) { 2007e41f4b71Sopenharmony_ci console.error(`error, code: ${error.code}, message: ${error.message}`); 2008e41f4b71Sopenharmony_ci } 2009e41f4b71Sopenharmony_ci }); 2010e41f4b71Sopenharmony_ci} catch(error) { 2011e41f4b71Sopenharmony_ci console.error(`catch error, code: ${(error as BusinessError).code}, message: ${(error as BusinessError).message}`); 2012e41f4b71Sopenharmony_ci} 2013e41f4b71Sopenharmony_ci``` 2014e41f4b71Sopenharmony_ci 2015e41f4b71Sopenharmony_ci## notifyFormsPrivacyProtected 2016e41f4b71Sopenharmony_ci 2017e41f4b71Sopenharmony_cinotifyFormsPrivacyProtected(formIds: Array\<string\>, isProtected: boolean): Promise\<void\> 2018e41f4b71Sopenharmony_ci 2019e41f4b71Sopenharmony_ci通知指定卡片隐私保护状态改变。使用Promise异步回调。 2020e41f4b71Sopenharmony_ci 2021e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.REQUIRE_FORM 2022e41f4b71Sopenharmony_ci 2023e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Ability.Form 2024e41f4b71Sopenharmony_ci 2025e41f4b71Sopenharmony_ci**参数:** 2026e41f4b71Sopenharmony_ci 2027e41f4b71Sopenharmony_ci| 参数名 | 类型 | 必填 | 说明 | 2028e41f4b71Sopenharmony_ci| ----------- | --------------- | ---- | -------------------------------- | 2029e41f4b71Sopenharmony_ci| formIds | Array\<string\> | 是 | 需要修改隐私保护的卡片标识列表。 | 2030e41f4b71Sopenharmony_ci| isProtected | boolean | 是 | 是否进行隐私保护。 | 2031e41f4b71Sopenharmony_ci 2032e41f4b71Sopenharmony_ci**返回值:** 2033e41f4b71Sopenharmony_ci 2034e41f4b71Sopenharmony_ci| 类型 | 说明 | 2035e41f4b71Sopenharmony_ci| ------------------- | ------------------------- | 2036e41f4b71Sopenharmony_ci| Promise<void> | 无返回结果的Promise对象。 | 2037e41f4b71Sopenharmony_ci 2038e41f4b71Sopenharmony_ci**错误码:** 2039e41f4b71Sopenharmony_ci 2040e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 | 2041e41f4b71Sopenharmony_ci| -------- | -------- | 2042e41f4b71Sopenharmony_ci| 201 | Permissions denied. | 2043e41f4b71Sopenharmony_ci| 202 | The application is not a system application. | 2044e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. | 2045e41f4b71Sopenharmony_ci| 16500050 | IPC connection error. | 2046e41f4b71Sopenharmony_ci| 16500060 | Service connection error. | 2047e41f4b71Sopenharmony_ci| 16501000 | An internal functional error occurred. | 2048e41f4b71Sopenharmony_ci 2049e41f4b71Sopenharmony_ci以上错误码的详细介绍请参见[卡片错误码](errorcode-form.md)。 2050e41f4b71Sopenharmony_ci 2051e41f4b71Sopenharmony_ci```ts 2052e41f4b71Sopenharmony_ciimport { formHost } from '@kit.FormKit'; 2053e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 2054e41f4b71Sopenharmony_ci 2055e41f4b71Sopenharmony_cilet formIds: string[] = new Array('12400633174999288', '12400633174999289'); 2056e41f4b71Sopenharmony_citry { 2057e41f4b71Sopenharmony_ci formHost.notifyFormsPrivacyProtected(formIds, true).then(() => { 2058e41f4b71Sopenharmony_ci console.log('formHost notifyFormsPrivacyProtected success'); 2059e41f4b71Sopenharmony_ci }).catch((error: BusinessError) => { 2060e41f4b71Sopenharmony_ci console.error(`error, code: ${error.code}, message: ${error.message}`); 2061e41f4b71Sopenharmony_ci }); 2062e41f4b71Sopenharmony_ci} catch(error) { 2063e41f4b71Sopenharmony_ci console.error(`catch error, code: ${(error as BusinessError).code}, message: ${(error as BusinessError).message}`); 2064e41f4b71Sopenharmony_ci} 2065e41f4b71Sopenharmony_ci``` 2066e41f4b71Sopenharmony_ci 2067e41f4b71Sopenharmony_ci## acquireFormData<sup>10+</sup> 2068e41f4b71Sopenharmony_ci 2069e41f4b71Sopenharmony_ciacquireFormData(formId: string, callback: AsyncCallback\<Record\<string, Object>>): void 2070e41f4b71Sopenharmony_ci 2071e41f4b71Sopenharmony_ci请求卡片提供方数据。使用callback异步回调。 2072e41f4b71Sopenharmony_ci 2073e41f4b71Sopenharmony_ci**模型约束:** 此接口仅可在Stage模型下使用。 2074e41f4b71Sopenharmony_ci 2075e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.REQUIRE_FORM 2076e41f4b71Sopenharmony_ci 2077e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Ability.Form 2078e41f4b71Sopenharmony_ci 2079e41f4b71Sopenharmony_ci**参数:** 2080e41f4b71Sopenharmony_ci 2081e41f4b71Sopenharmony_ci| 参数名 | 类型 | 必填 | 说明 | 2082e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ------- | 2083e41f4b71Sopenharmony_ci| formId | string | 是 | 卡片标识。 | 2084e41f4b71Sopenharmony_ci| callback | AsyncCallback\<Record\<string, Object> | 是 | 以callback方式返回接口运行结果及分享数据。 | 2085e41f4b71Sopenharmony_ci 2086e41f4b71Sopenharmony_ci**错误码:** 2087e41f4b71Sopenharmony_ci 2088e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 | 2089e41f4b71Sopenharmony_ci| -------- | -------- | 2090e41f4b71Sopenharmony_ci| 201 | Permissions denied. | 2091e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. | 2092e41f4b71Sopenharmony_ci| 16500050 | IPC connection error. | 2093e41f4b71Sopenharmony_ci| 16500060 | Service connection error. | 2094e41f4b71Sopenharmony_ci| 16500100 | Failed to obtain the configuration information. | 2095e41f4b71Sopenharmony_ci| 16501000 | An internal functional error occurred. | 2096e41f4b71Sopenharmony_ci 2097e41f4b71Sopenharmony_ci以上错误码的详细介绍请参见[卡片错误码](errorcode-form.md)。 2098e41f4b71Sopenharmony_ci 2099e41f4b71Sopenharmony_ci**示例:** 2100e41f4b71Sopenharmony_ci 2101e41f4b71Sopenharmony_ci```ts 2102e41f4b71Sopenharmony_ciimport { formHost } from '@kit.FormKit'; 2103e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 2104e41f4b71Sopenharmony_ci 2105e41f4b71Sopenharmony_cilet formId: string = '12400633174999288'; 2106e41f4b71Sopenharmony_citry { 2107e41f4b71Sopenharmony_ci formHost.acquireFormData(formId, (error, data) => { 2108e41f4b71Sopenharmony_ci if (error) { 2109e41f4b71Sopenharmony_ci console.error(`error, code: ${error.code}, message: ${error.message}`); 2110e41f4b71Sopenharmony_ci } else { 2111e41f4b71Sopenharmony_ci console.log(`formHost acquireFormData, data: ${JSON.stringify(data)}`); 2112e41f4b71Sopenharmony_ci } 2113e41f4b71Sopenharmony_ci }); 2114e41f4b71Sopenharmony_ci} catch(error) { 2115e41f4b71Sopenharmony_ci console.error(`catch error, code: ${(error as BusinessError).code}, message: ${(error as BusinessError).message}`); 2116e41f4b71Sopenharmony_ci} 2117e41f4b71Sopenharmony_ci``` 2118e41f4b71Sopenharmony_ci 2119e41f4b71Sopenharmony_ci## acquireFormData<sup>10+</sup> 2120e41f4b71Sopenharmony_ci 2121e41f4b71Sopenharmony_ciacquireFormData(formId: string): Promise\<Record\<string, Object>> 2122e41f4b71Sopenharmony_ci 2123e41f4b71Sopenharmony_ci请求卡片提供方数据。使用Promise异步回调。 2124e41f4b71Sopenharmony_ci 2125e41f4b71Sopenharmony_ci**模型约束:** 此接口仅可在Stage模型下使用。 2126e41f4b71Sopenharmony_ci 2127e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.REQUIRE_FORM 2128e41f4b71Sopenharmony_ci 2129e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Ability.Form 2130e41f4b71Sopenharmony_ci 2131e41f4b71Sopenharmony_ci**参数:** 2132e41f4b71Sopenharmony_ci 2133e41f4b71Sopenharmony_ci| 参数名 | 类型 | 必填 | 说明 | 2134e41f4b71Sopenharmony_ci| ----------- | --------------- | ---- | -------------------------------- | 2135e41f4b71Sopenharmony_ci| formId | string | 是 | 卡片标识。 | 2136e41f4b71Sopenharmony_ci 2137e41f4b71Sopenharmony_ci**返回值:** 2138e41f4b71Sopenharmony_ci 2139e41f4b71Sopenharmony_ci| 类型 | 说明 | 2140e41f4b71Sopenharmony_ci| ------------------- | ------------------------- | 2141e41f4b71Sopenharmony_ci| Promise\<Record\<string, Object>>| 以Promise方式返回接口运行结果及分享数据。 | 2142e41f4b71Sopenharmony_ci 2143e41f4b71Sopenharmony_ci**错误码:** 2144e41f4b71Sopenharmony_ci 2145e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 | 2146e41f4b71Sopenharmony_ci| -------- | -------- | 2147e41f4b71Sopenharmony_ci| 201 | Permissions denied. | 2148e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. | 2149e41f4b71Sopenharmony_ci| 16500050 | IPC connection error. | 2150e41f4b71Sopenharmony_ci| 16500060 | Service connection error. | 2151e41f4b71Sopenharmony_ci| 16500100 | Failed to obtain the configuration information. | 2152e41f4b71Sopenharmony_ci| 16501000 | An internal functional error occurred. | 2153e41f4b71Sopenharmony_ci 2154e41f4b71Sopenharmony_ci以上错误码的详细介绍请参见[卡片错误码](errorcode-form.md)。 2155e41f4b71Sopenharmony_ci 2156e41f4b71Sopenharmony_ci```ts 2157e41f4b71Sopenharmony_ciimport { formHost } from '@kit.FormKit'; 2158e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 2159e41f4b71Sopenharmony_ci 2160e41f4b71Sopenharmony_cilet formId: string = '12400633174999288'; 2161e41f4b71Sopenharmony_citry { 2162e41f4b71Sopenharmony_ci formHost.acquireFormData(formId).then((data) => { 2163e41f4b71Sopenharmony_ci console.log('formHost acquireFormData success' + data); 2164e41f4b71Sopenharmony_ci }).catch((error: BusinessError) => { 2165e41f4b71Sopenharmony_ci console.error(`error, code: ${error.code}, message: ${error.message}`); 2166e41f4b71Sopenharmony_ci }); 2167e41f4b71Sopenharmony_ci} catch(error) { 2168e41f4b71Sopenharmony_ci console.error(`catch error, code: ${(error as BusinessError).code}, message: ${(error as BusinessError).message}`); 2169e41f4b71Sopenharmony_ci} 2170e41f4b71Sopenharmony_ci``` 2171e41f4b71Sopenharmony_ci 2172e41f4b71Sopenharmony_ci## setRouterProxy<sup>11+</sup> 2173e41f4b71Sopenharmony_ci 2174e41f4b71Sopenharmony_cisetRouterProxy(formIds: Array<string>, proxy: Callback<Want>, callback: AsyncCallback<void>): void 2175e41f4b71Sopenharmony_ci 2176e41f4b71Sopenharmony_ci设置卡片跳转代理。使用callback异步回调,返回卡片跳转所需要Want信息。 2177e41f4b71Sopenharmony_ci 2178e41f4b71Sopenharmony_ci 2179e41f4b71Sopenharmony_ci 2180e41f4b71Sopenharmony_ci> **说明:** 2181e41f4b71Sopenharmony_ci> 2182e41f4b71Sopenharmony_ci>- 一般情况下,对于桌面添加的卡片,当卡片触发router跳转时,卡片框架会检测其跳转目的地是否合理,是否有跳转权限,然后进行应用跳转。如果卡片使用方添加了卡片,并设置了卡片跳转代理,那么卡片触发router跳转时,卡片框架不会再为其进行跳转操作,会把包含跳转目的地的want参数返回给卡片使用方。因此如果卡片使用方希望使用该want信息进行应用跳转,需要确保自身拥有应用跳转的权限,参考 2183e41f4b71Sopenharmony_ci[UIAbilityContext.startAbility()](../apis-ability-kit/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextstartability)接口。 2184e41f4b71Sopenharmony_ci> 2185e41f4b71Sopenharmony_ci>- 一个formId最多只能设置一个跳转代理,多次设置后,最后设置的proxy生效。 2186e41f4b71Sopenharmony_ci 2187e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.REQUIRE_FORM 2188e41f4b71Sopenharmony_ci 2189e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Ability.Form 2190e41f4b71Sopenharmony_ci 2191e41f4b71Sopenharmony_ci**参数:** 2192e41f4b71Sopenharmony_ci 2193e41f4b71Sopenharmony_ci| 参数名 | 类型 | 必填 | 说明 | 2194e41f4b71Sopenharmony_ci| -------- | ------------------------- | ---- | ------------------------------------------------------------ | 2195e41f4b71Sopenharmony_ci| formIds | Array<string> | 是 | 卡片标识数组。 | 2196e41f4b71Sopenharmony_ci| proxy | Callback<Want> | 是 | 回调函数。返回跳转所需要的Want信息。 | 2197e41f4b71Sopenharmony_ci| callback | AsyncCallback<void> | 是 | 回调函数,当指定卡片设置router跳转代理成功时,error为undefined;否则抛出异常。 | 2198e41f4b71Sopenharmony_ci 2199e41f4b71Sopenharmony_ci**错误码:** 2200e41f4b71Sopenharmony_ci 2201e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 | 2202e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ | 2203e41f4b71Sopenharmony_ci| 201 | Permissions denied. | 2204e41f4b71Sopenharmony_ci| 202 | The application is not a system application. | 2205e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. | 2206e41f4b71Sopenharmony_ci| 16500050 | IPC connection error. | 2207e41f4b71Sopenharmony_ci| 16500060 | Service connection error. | 2208e41f4b71Sopenharmony_ci| 16501000 | An internal functional error occurred. | 2209e41f4b71Sopenharmony_ci| 16501003 | The form cannot be operated by the current application. | 2210e41f4b71Sopenharmony_ci 2211e41f4b71Sopenharmony_ci以上错误码的详细介绍请参见[卡片错误码](errorcode-form.md)。 2212e41f4b71Sopenharmony_ci 2213e41f4b71Sopenharmony_ci**示例:** 2214e41f4b71Sopenharmony_ci 2215e41f4b71Sopenharmony_ci```ts 2216e41f4b71Sopenharmony_ciimport { common, Want } from '@kit.AbilityKit'; 2217e41f4b71Sopenharmony_ciimport { formHost } from '@kit.FormKit'; 2218e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 2219e41f4b71Sopenharmony_ci 2220e41f4b71Sopenharmony_ci@Entry 2221e41f4b71Sopenharmony_ci@Component 2222e41f4b71Sopenharmony_cistruct CardExample { 2223e41f4b71Sopenharmony_ci private context = getContext(this) as common.UIAbilityContext; 2224e41f4b71Sopenharmony_ci @State formId: number = 0; 2225e41f4b71Sopenharmony_ci @State fwidth: number = 420; 2226e41f4b71Sopenharmony_ci @State fheight: number = 280; 2227e41f4b71Sopenharmony_ci 2228e41f4b71Sopenharmony_ci build() { 2229e41f4b71Sopenharmony_ci Column() { 2230e41f4b71Sopenharmony_ci FormComponent({ 2231e41f4b71Sopenharmony_ci id: this.formId, 2232e41f4b71Sopenharmony_ci name: "widget", 2233e41f4b71Sopenharmony_ci bundle: "com.example.cardprovider", 2234e41f4b71Sopenharmony_ci ability: "EntryFormAbility", 2235e41f4b71Sopenharmony_ci module: "entry", 2236e41f4b71Sopenharmony_ci dimension: FormDimension.Dimension_2_2, 2237e41f4b71Sopenharmony_ci temporary: false, 2238e41f4b71Sopenharmony_ci }) 2239e41f4b71Sopenharmony_ci .allowUpdate(true) 2240e41f4b71Sopenharmony_ci .size({ width: this.fwidth, height: this.fheight }) 2241e41f4b71Sopenharmony_ci .visibility(Visibility.Visible) 2242e41f4b71Sopenharmony_ci .onAcquired((form) => { 2243e41f4b71Sopenharmony_ci console.log(`testTag form info : ${JSON.stringify(form)}`); 2244e41f4b71Sopenharmony_ci this.formId = form.id; 2245e41f4b71Sopenharmony_ci try { 2246e41f4b71Sopenharmony_ci let formIds: string[] = [this.formId.toString()]; 2247e41f4b71Sopenharmony_ci formHost.setRouterProxy(formIds, (want: Want) => { 2248e41f4b71Sopenharmony_ci console.info(`formHost recv router event, want: ${JSON.stringify(want)}`); 2249e41f4b71Sopenharmony_ci // 卡片使用方自己处理跳转 2250e41f4b71Sopenharmony_ci this.context.startAbility(want, (err: BusinessError) => { 2251e41f4b71Sopenharmony_ci console.info(`formHost startAbility error, code: ${err.code}, message: ${err.message}`); 2252e41f4b71Sopenharmony_ci }); 2253e41f4b71Sopenharmony_ci }, (err: BusinessError) => { 2254e41f4b71Sopenharmony_ci console.error(`set router proxy error, code: ${err.code}, message: ${err.message}`); 2255e41f4b71Sopenharmony_ci }) 2256e41f4b71Sopenharmony_ci } catch (e) { 2257e41f4b71Sopenharmony_ci console.log('formHost setRouterProxy catch exception: ' + JSON.stringify(e)); 2258e41f4b71Sopenharmony_ci } 2259e41f4b71Sopenharmony_ci }) 2260e41f4b71Sopenharmony_ci } 2261e41f4b71Sopenharmony_ci .width('100%') 2262e41f4b71Sopenharmony_ci .height('100%') 2263e41f4b71Sopenharmony_ci } 2264e41f4b71Sopenharmony_ci} 2265e41f4b71Sopenharmony_ci``` 2266e41f4b71Sopenharmony_ci 2267e41f4b71Sopenharmony_ci## setRouterProxy<sup>11+</sup> 2268e41f4b71Sopenharmony_ci 2269e41f4b71Sopenharmony_cisetRouterProxy(formIds: Array<string>, proxy: Callback<Want>): Promise<void> 2270e41f4b71Sopenharmony_ci 2271e41f4b71Sopenharmony_ci设置卡片跳转代理。使用Promise异步回调,返回卡片跳转所需要Want信息。 2272e41f4b71Sopenharmony_ci 2273e41f4b71Sopenharmony_ci> **说明:** 2274e41f4b71Sopenharmony_ci> 2275e41f4b71Sopenharmony_ci>- 一般情况下,对于桌面添加的卡片,当卡片触发router跳转时,卡片框架会检测其跳转目的地是否合理,是否有跳转权限,然后进行应用跳转。如果卡片使用方添加了卡片,并设置了卡片跳转代理,那么卡片触发router跳转时,卡片框架不会再为其进行跳转操作,会把包含跳转目的地的want参数返回给卡片使用方。因此如果卡片使用方希望使用该want信息进行应用跳转,需要确保自身拥有应用跳转的权限,参考[UIAbilityContext.startAbility()](../apis-ability-kit/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextstartability)接口。 2276e41f4b71Sopenharmony_ci> 2277e41f4b71Sopenharmony_ci>- 一个formId最多只能设置一个跳转代理,多次设置后,最后设置的proxy生效。 2278e41f4b71Sopenharmony_ci 2279e41f4b71Sopenharmony_ci 2280e41f4b71Sopenharmony_ci 2281e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.REQUIRE_FORM 2282e41f4b71Sopenharmony_ci 2283e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Ability.Form 2284e41f4b71Sopenharmony_ci 2285e41f4b71Sopenharmony_ci**参数:** 2286e41f4b71Sopenharmony_ci 2287e41f4b71Sopenharmony_ci| 参数名 | 类型 | 必填 | 说明 | 2288e41f4b71Sopenharmony_ci| ------- | -------------------- | ---- | ------------------------------------ | 2289e41f4b71Sopenharmony_ci| formIds | Array<string> | 是 | 卡片标识数组。 | 2290e41f4b71Sopenharmony_ci| proxy | Callback<Want> | 是 | 回调函数。返回跳转所需要的Want信息。 | 2291e41f4b71Sopenharmony_ci 2292e41f4b71Sopenharmony_ci**返回值:** 2293e41f4b71Sopenharmony_ci 2294e41f4b71Sopenharmony_ci| 类型 | 说明 | 2295e41f4b71Sopenharmony_ci| ------------------- | ------------------------- | 2296e41f4b71Sopenharmony_ci| Promise<void> | 无返回结果的Promise对象。 | 2297e41f4b71Sopenharmony_ci 2298e41f4b71Sopenharmony_ci**错误码:** 2299e41f4b71Sopenharmony_ci 2300e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 | 2301e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ | 2302e41f4b71Sopenharmony_ci| 201 | Permissions denied. | 2303e41f4b71Sopenharmony_ci| 202 | The application is not a system application. | 2304e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. | 2305e41f4b71Sopenharmony_ci| 16500050 | IPC connection error. | 2306e41f4b71Sopenharmony_ci| 16500060 | Service connection error. | 2307e41f4b71Sopenharmony_ci| 16501000 | An internal functional error occurred. | 2308e41f4b71Sopenharmony_ci| 16501003 | The form cannot be operated by the current application. | 2309e41f4b71Sopenharmony_ci 2310e41f4b71Sopenharmony_ci以上错误码的详细介绍请参见[卡片错误码](errorcode-form.md)。 2311e41f4b71Sopenharmony_ci 2312e41f4b71Sopenharmony_ci**示例:** 2313e41f4b71Sopenharmony_ci 2314e41f4b71Sopenharmony_ci```ts 2315e41f4b71Sopenharmony_ciimport { formHost } from '@kit.FormKit'; 2316e41f4b71Sopenharmony_ciimport { common, Want } from '@kit.AbilityKit'; 2317e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 2318e41f4b71Sopenharmony_ci 2319e41f4b71Sopenharmony_ci@Entry 2320e41f4b71Sopenharmony_ci@Component 2321e41f4b71Sopenharmony_cistruct CardExample { 2322e41f4b71Sopenharmony_ci private context = getContext(this) as common.UIAbilityContext; 2323e41f4b71Sopenharmony_ci @State formId: number = 0; 2324e41f4b71Sopenharmony_ci @State fwidth: number = 420; 2325e41f4b71Sopenharmony_ci @State fheight: number = 280; 2326e41f4b71Sopenharmony_ci 2327e41f4b71Sopenharmony_ci build() { 2328e41f4b71Sopenharmony_ci Column() { 2329e41f4b71Sopenharmony_ci FormComponent({ 2330e41f4b71Sopenharmony_ci id: this.formId, 2331e41f4b71Sopenharmony_ci name: "widget", 2332e41f4b71Sopenharmony_ci bundle: "com.example.cardprovider", 2333e41f4b71Sopenharmony_ci ability: "EntryFormAbility", 2334e41f4b71Sopenharmony_ci module: "entry", 2335e41f4b71Sopenharmony_ci dimension: FormDimension.Dimension_2_2, 2336e41f4b71Sopenharmony_ci temporary: false, 2337e41f4b71Sopenharmony_ci }) 2338e41f4b71Sopenharmony_ci .allowUpdate(true) 2339e41f4b71Sopenharmony_ci .size({ width: this.fwidth, height: this.fheight }) 2340e41f4b71Sopenharmony_ci .visibility(Visibility.Visible) 2341e41f4b71Sopenharmony_ci .onAcquired((form) => { 2342e41f4b71Sopenharmony_ci console.log(`testTag form info : ${JSON.stringify(form)}`); 2343e41f4b71Sopenharmony_ci this.formId = form.id; 2344e41f4b71Sopenharmony_ci try { 2345e41f4b71Sopenharmony_ci let formIds: string[] = [this.formId.toString()]; 2346e41f4b71Sopenharmony_ci formHost.setRouterProxy(formIds, (want: Want) => { 2347e41f4b71Sopenharmony_ci console.info(`formHost recv router event, want: ${JSON.stringify(want)}`); 2348e41f4b71Sopenharmony_ci // 卡片使用方自己处理跳转 2349e41f4b71Sopenharmony_ci this.context.startAbility(want, (err: BusinessError) => { 2350e41f4b71Sopenharmony_ci console.info(`formHost startAbility error, code: ${err.code}, message: ${err.message}`); 2351e41f4b71Sopenharmony_ci }); 2352e41f4b71Sopenharmony_ci }).then(() => { 2353e41f4b71Sopenharmony_ci console.info('formHost set router proxy success'); 2354e41f4b71Sopenharmony_ci }).catch((err: BusinessError) => { 2355e41f4b71Sopenharmony_ci console.error(`set router proxy error, code: ${err.code}, message: ${err.message}`); 2356e41f4b71Sopenharmony_ci }) 2357e41f4b71Sopenharmony_ci } catch (e) { 2358e41f4b71Sopenharmony_ci console.log('formHost setRouterProxy catch exception: ' + JSON.stringify(e)); 2359e41f4b71Sopenharmony_ci } 2360e41f4b71Sopenharmony_ci }) 2361e41f4b71Sopenharmony_ci } 2362e41f4b71Sopenharmony_ci .width('100%') 2363e41f4b71Sopenharmony_ci .height('100%') 2364e41f4b71Sopenharmony_ci } 2365e41f4b71Sopenharmony_ci} 2366e41f4b71Sopenharmony_ci``` 2367e41f4b71Sopenharmony_ci 2368e41f4b71Sopenharmony_ci## clearRouterProxy<sup>11+</sup> 2369e41f4b71Sopenharmony_ci 2370e41f4b71Sopenharmony_ciclearRouterProxy(formIds:Array<string>, callback: AsyncCallback<void>): void 2371e41f4b71Sopenharmony_ci 2372e41f4b71Sopenharmony_ci清除卡片跳转代理。使用callback异步回调。 2373e41f4b71Sopenharmony_ci 2374e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.REQUIRE_FORM 2375e41f4b71Sopenharmony_ci 2376e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Ability.Form 2377e41f4b71Sopenharmony_ci 2378e41f4b71Sopenharmony_ci**参数:** 2379e41f4b71Sopenharmony_ci 2380e41f4b71Sopenharmony_ci| 参数名 | 类型 | 必填 | 说明 | 2381e41f4b71Sopenharmony_ci| -------- | ------------------------- | ---- | ------------------------------------------------------------ | 2382e41f4b71Sopenharmony_ci| formIds | Array<string>; | 是 | 卡片标识数组。 | 2383e41f4b71Sopenharmony_ci| callback | AsyncCallback<void> | 是 | 回调函数,当指定卡片取消router跳转代理成功时,error为undefined;否则抛出异常。 | 2384e41f4b71Sopenharmony_ci 2385e41f4b71Sopenharmony_ci**错误码:** 2386e41f4b71Sopenharmony_ci 2387e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 | 2388e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ | 2389e41f4b71Sopenharmony_ci| 201 | Permissions denied. | 2390e41f4b71Sopenharmony_ci| 202 | The application is not a system application. | 2391e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. | 2392e41f4b71Sopenharmony_ci| 16500050 | IPC connection error. | 2393e41f4b71Sopenharmony_ci| 16500060 | Service connection error. | 2394e41f4b71Sopenharmony_ci| 16501000 | An internal functional error occurred. | 2395e41f4b71Sopenharmony_ci| 16501003 | The form cannot be operated by the current application. | 2396e41f4b71Sopenharmony_ci 2397e41f4b71Sopenharmony_ci以上错误码的详细介绍请参见[卡片错误码](errorcode-form.md)。 2398e41f4b71Sopenharmony_ci 2399e41f4b71Sopenharmony_ci**示例:** 2400e41f4b71Sopenharmony_ci 2401e41f4b71Sopenharmony_ci```ts 2402e41f4b71Sopenharmony_ciimport { formHost } from '@kit.FormKit'; 2403e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 2404e41f4b71Sopenharmony_ci 2405e41f4b71Sopenharmony_citry { 2406e41f4b71Sopenharmony_ci let formIds: string[] = ['12400633174999288']; 2407e41f4b71Sopenharmony_ci formHost.clearRouterProxy(formIds, (err: BusinessError) => { 2408e41f4b71Sopenharmony_ci if (err) { 2409e41f4b71Sopenharmony_ci console.error(`formHost clear router proxy error, code: ${err.code}, message: ${err.message}`); 2410e41f4b71Sopenharmony_ci } 2411e41f4b71Sopenharmony_ci }); 2412e41f4b71Sopenharmony_ci} catch (error) { 2413e41f4b71Sopenharmony_ci console.error(`catch error, code: ${(error as BusinessError).code}, message: ${(error as BusinessError).message}`); 2414e41f4b71Sopenharmony_ci} 2415e41f4b71Sopenharmony_ci``` 2416e41f4b71Sopenharmony_ci 2417e41f4b71Sopenharmony_ci## clearRouterProxy<sup>11+</sup> 2418e41f4b71Sopenharmony_ci 2419e41f4b71Sopenharmony_ciclearRouterProxy(formIds:Array<string>): Promise<void> 2420e41f4b71Sopenharmony_ci 2421e41f4b71Sopenharmony_ci清除卡片跳转代理。使用Promise异步回调。 2422e41f4b71Sopenharmony_ci 2423e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.REQUIRE_FORM 2424e41f4b71Sopenharmony_ci 2425e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Ability.Form 2426e41f4b71Sopenharmony_ci 2427e41f4b71Sopenharmony_ci**参数:** 2428e41f4b71Sopenharmony_ci 2429e41f4b71Sopenharmony_ci| 参数名 | 类型 | 必填 | 说明 | 2430e41f4b71Sopenharmony_ci| ------- | ------------------- | ---- | -------------- | 2431e41f4b71Sopenharmony_ci| formIds | Array<string> | 是 | 卡片标识数组。 | 2432e41f4b71Sopenharmony_ci 2433e41f4b71Sopenharmony_ci**返回值:** 2434e41f4b71Sopenharmony_ci 2435e41f4b71Sopenharmony_ci| 类型 | 说明 | 2436e41f4b71Sopenharmony_ci| ------------------- | ------------------------- | 2437e41f4b71Sopenharmony_ci| Promise<void> | 无返回结果的Promise对象。 | 2438e41f4b71Sopenharmony_ci 2439e41f4b71Sopenharmony_ci**错误码:** 2440e41f4b71Sopenharmony_ci 2441e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 | 2442e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ | 2443e41f4b71Sopenharmony_ci| 201 | Permissions denied. | 2444e41f4b71Sopenharmony_ci| 202 | The application is not a system application. | 2445e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. | 2446e41f4b71Sopenharmony_ci| 16500050 | IPC connection error. | 2447e41f4b71Sopenharmony_ci| 16500060 | Service connection error. | 2448e41f4b71Sopenharmony_ci| 16501000 | An internal functional error occurred. | 2449e41f4b71Sopenharmony_ci| 16501003 | The form cannot be operated by the current application. | 2450e41f4b71Sopenharmony_ci 2451e41f4b71Sopenharmony_ci以上错误码的详细介绍请参见[卡片错误码](errorcode-form.md)。 2452e41f4b71Sopenharmony_ci 2453e41f4b71Sopenharmony_ci**示例:** 2454e41f4b71Sopenharmony_ci 2455e41f4b71Sopenharmony_ci```ts 2456e41f4b71Sopenharmony_ciimport { formHost } from '@kit.FormKit'; 2457e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 2458e41f4b71Sopenharmony_ci 2459e41f4b71Sopenharmony_citry { 2460e41f4b71Sopenharmony_ci let formIds: string[] = ['12400633174999288']; 2461e41f4b71Sopenharmony_ci formHost.clearRouterProxy(formIds).then(() => { 2462e41f4b71Sopenharmony_ci console.log('formHost clear rourter proxy success'); 2463e41f4b71Sopenharmony_ci }).catch((err: BusinessError) => { 2464e41f4b71Sopenharmony_ci console.error(`formHost clear router proxy error, code: ${err.code}, message: ${err.message}`); 2465e41f4b71Sopenharmony_ci }); 2466e41f4b71Sopenharmony_ci} catch (error) { 2467e41f4b71Sopenharmony_ci console.error(`catch error, code: ${(error as BusinessError).code}, message: ${(error as BusinessError).message}`); 2468e41f4b71Sopenharmony_ci} 2469e41f4b71Sopenharmony_ci``` 2470e41f4b71Sopenharmony_ci## setFormsRecyclable<sup>11+</sup> 2471e41f4b71Sopenharmony_ci 2472e41f4b71Sopenharmony_cisetFormsRecyclable(formIds:Array<string>, callback: AsyncCallback<void>): void 2473e41f4b71Sopenharmony_ci 2474e41f4b71Sopenharmony_ci设置卡片可回收。使用callback异步回调。 2475e41f4b71Sopenharmony_ci 2476e41f4b71Sopenharmony_ci**模型约束:** 此接口仅可在Stage模型下使用。 2477e41f4b71Sopenharmony_ci 2478e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.REQUIRE_FORM 2479e41f4b71Sopenharmony_ci 2480e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Ability.Form 2481e41f4b71Sopenharmony_ci 2482e41f4b71Sopenharmony_ci**参数:** 2483e41f4b71Sopenharmony_ci 2484e41f4b71Sopenharmony_ci| 参数名 | 类型 | 必填 | 说明 | 2485e41f4b71Sopenharmony_ci| -------- | ------------------------- | ---- | ------------------------------------------------------------ | 2486e41f4b71Sopenharmony_ci| formIds | Array<string>; | 是 | 卡片标识数组。 | 2487e41f4b71Sopenharmony_ci| callback | AsyncCallback<void> | 是 | 回调函数,当设置卡片可回收成功时,error为undefined;否则抛出异常。 | 2488e41f4b71Sopenharmony_ci 2489e41f4b71Sopenharmony_ci**错误码:** 2490e41f4b71Sopenharmony_ci 2491e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 | 2492e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ | 2493e41f4b71Sopenharmony_ci| 201 | Permissions denied. | 2494e41f4b71Sopenharmony_ci| 202 | The application is not a system application. | 2495e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. | 2496e41f4b71Sopenharmony_ci| 16500050 | IPC connection error. | 2497e41f4b71Sopenharmony_ci| 16500060 | Service connection error. | 2498e41f4b71Sopenharmony_ci| 16501000 | An internal functional error occurred. | 2499e41f4b71Sopenharmony_ci 2500e41f4b71Sopenharmony_ci以上错误码的详细介绍请参见[卡片错误码](errorcode-form.md)。 2501e41f4b71Sopenharmony_ci 2502e41f4b71Sopenharmony_ci**示例:** 2503e41f4b71Sopenharmony_ci 2504e41f4b71Sopenharmony_ci```ts 2505e41f4b71Sopenharmony_ciimport { formHost } from '@kit.FormKit'; 2506e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 2507e41f4b71Sopenharmony_ci 2508e41f4b71Sopenharmony_citry { 2509e41f4b71Sopenharmony_ci let formIds: string[] = ['12400633174999288']; 2510e41f4b71Sopenharmony_ci formHost.setFormsRecyclable(formIds, (err: BusinessError) => { 2511e41f4b71Sopenharmony_ci if (err) { 2512e41f4b71Sopenharmony_ci console.error(`setFormsRecyclable error, code: ${err.code}, message: ${err.message}`); 2513e41f4b71Sopenharmony_ci } 2514e41f4b71Sopenharmony_ci }); 2515e41f4b71Sopenharmony_ci} catch (error) { 2516e41f4b71Sopenharmony_ci console.error(`catch error, code: ${(error as BusinessError).code}, message: ${(error as BusinessError).message}`); 2517e41f4b71Sopenharmony_ci} 2518e41f4b71Sopenharmony_ci``` 2519e41f4b71Sopenharmony_ci 2520e41f4b71Sopenharmony_ci## setFormsRecyclable<sup>11+</sup> 2521e41f4b71Sopenharmony_ci 2522e41f4b71Sopenharmony_cisetFormsRecyclable(formIds:Array<string>): Promise<void> 2523e41f4b71Sopenharmony_ci 2524e41f4b71Sopenharmony_ci设置卡片可回收。使用Promise异步回调。 2525e41f4b71Sopenharmony_ci 2526e41f4b71Sopenharmony_ci**模型约束:** 此接口仅可在Stage模型下使用。 2527e41f4b71Sopenharmony_ci 2528e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.REQUIRE_FORM 2529e41f4b71Sopenharmony_ci 2530e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Ability.Form 2531e41f4b71Sopenharmony_ci 2532e41f4b71Sopenharmony_ci**参数:** 2533e41f4b71Sopenharmony_ci 2534e41f4b71Sopenharmony_ci| 参数名 | 类型 | 必填 | 说明 | 2535e41f4b71Sopenharmony_ci| ------- | ------------------- | ---- | -------------- | 2536e41f4b71Sopenharmony_ci| formIds | Array<string> | 是 | 卡片标识数组。 | 2537e41f4b71Sopenharmony_ci 2538e41f4b71Sopenharmony_ci**返回值:** 2539e41f4b71Sopenharmony_ci 2540e41f4b71Sopenharmony_ci| 类型 | 说明 | 2541e41f4b71Sopenharmony_ci| ------------------- | ------------------------- | 2542e41f4b71Sopenharmony_ci| Promise<void> | 无返回结果的Promise对象。 | 2543e41f4b71Sopenharmony_ci 2544e41f4b71Sopenharmony_ci**错误码:** 2545e41f4b71Sopenharmony_ci 2546e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 | 2547e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ | 2548e41f4b71Sopenharmony_ci| 201 | Permissions denied. | 2549e41f4b71Sopenharmony_ci| 202 | The application is not a system application. | 2550e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. | 2551e41f4b71Sopenharmony_ci| 16500050 | IPC connection error. | 2552e41f4b71Sopenharmony_ci| 16500060 | Service connection error. | 2553e41f4b71Sopenharmony_ci| 16501000 | An internal functional error occurred. | 2554e41f4b71Sopenharmony_ci 2555e41f4b71Sopenharmony_ci以上错误码的详细介绍请参见[卡片错误码](errorcode-form.md)。 2556e41f4b71Sopenharmony_ci 2557e41f4b71Sopenharmony_ci**示例:** 2558e41f4b71Sopenharmony_ci 2559e41f4b71Sopenharmony_ci```ts 2560e41f4b71Sopenharmony_ciimport { formHost } from '@kit.FormKit'; 2561e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 2562e41f4b71Sopenharmony_ci 2563e41f4b71Sopenharmony_citry { 2564e41f4b71Sopenharmony_ci let formIds: string[] = ['12400633174999288']; 2565e41f4b71Sopenharmony_ci formHost.setFormsRecyclable(formIds).then(() => { 2566e41f4b71Sopenharmony_ci console.log('setFormsRecyclable success'); 2567e41f4b71Sopenharmony_ci }).catch((err: BusinessError) => { 2568e41f4b71Sopenharmony_ci console.error(`setFormsRecyclable error, code: ${err.code}, message: ${err.message}`); 2569e41f4b71Sopenharmony_ci }); 2570e41f4b71Sopenharmony_ci} catch (error) { 2571e41f4b71Sopenharmony_ci console.error(`catch error, code: ${(error as BusinessError).code}, message: ${(error as BusinessError).message}`); 2572e41f4b71Sopenharmony_ci} 2573e41f4b71Sopenharmony_ci``` 2574e41f4b71Sopenharmony_ci## recoverForms<sup>11+</sup> 2575e41f4b71Sopenharmony_ci 2576e41f4b71Sopenharmony_cirecoverForms(formIds:Array<string>, callback: AsyncCallback<void>): void 2577e41f4b71Sopenharmony_ci 2578e41f4b71Sopenharmony_ci恢复卡片。使用callback异步回调。 2579e41f4b71Sopenharmony_ci 2580e41f4b71Sopenharmony_ci**模型约束:** 此接口仅可在Stage模型下使用。 2581e41f4b71Sopenharmony_ci 2582e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.REQUIRE_FORM 2583e41f4b71Sopenharmony_ci 2584e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Ability.Form 2585e41f4b71Sopenharmony_ci 2586e41f4b71Sopenharmony_ci**参数:** 2587e41f4b71Sopenharmony_ci 2588e41f4b71Sopenharmony_ci| 参数名 | 类型 | 必填 | 说明 | 2589e41f4b71Sopenharmony_ci| -------- | ------------------------- | ---- | ------------------------------------------------------------ | 2590e41f4b71Sopenharmony_ci| formIds | Array<string>; | 是 | 卡片标识数组。 | 2591e41f4b71Sopenharmony_ci| callback | AsyncCallback<void> | 是 | 回调函数,当恢复卡片成功时,error为undefined;否则抛出异常。 | 2592e41f4b71Sopenharmony_ci 2593e41f4b71Sopenharmony_ci**错误码:** 2594e41f4b71Sopenharmony_ci 2595e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 | 2596e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ | 2597e41f4b71Sopenharmony_ci| 201 | Permissions denied. | 2598e41f4b71Sopenharmony_ci| 202 | The application is not a system application. | 2599e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. | 2600e41f4b71Sopenharmony_ci| 16500050 | IPC connection error. | 2601e41f4b71Sopenharmony_ci| 16500060 | Service connection error. | 2602e41f4b71Sopenharmony_ci| 16501000 | An internal functional error occurred. | 2603e41f4b71Sopenharmony_ci 2604e41f4b71Sopenharmony_ci以上错误码的详细介绍请参见[卡片错误码](errorcode-form.md)。 2605e41f4b71Sopenharmony_ci 2606e41f4b71Sopenharmony_ci**示例:** 2607e41f4b71Sopenharmony_ci 2608e41f4b71Sopenharmony_ci```ts 2609e41f4b71Sopenharmony_ciimport { formHost } from '@kit.FormKit'; 2610e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 2611e41f4b71Sopenharmony_ci 2612e41f4b71Sopenharmony_citry { 2613e41f4b71Sopenharmony_ci let formIds: string[] = ['12400633174999288']; 2614e41f4b71Sopenharmony_ci formHost.recoverForms(formIds, (err: BusinessError) => { 2615e41f4b71Sopenharmony_ci if (err) { 2616e41f4b71Sopenharmony_ci console.error(`recoverForms error, code: ${err.code}, message: ${err.message}`); 2617e41f4b71Sopenharmony_ci } 2618e41f4b71Sopenharmony_ci }); 2619e41f4b71Sopenharmony_ci} catch (error) { 2620e41f4b71Sopenharmony_ci console.error(`catch error, code: ${(error as BusinessError).code}, message: ${(error as BusinessError).message}`); 2621e41f4b71Sopenharmony_ci} 2622e41f4b71Sopenharmony_ci``` 2623e41f4b71Sopenharmony_ci## recoverForms<sup>11+</sup> 2624e41f4b71Sopenharmony_ci 2625e41f4b71Sopenharmony_cirecoverForms(formIds: Array<string>): Promise<void> 2626e41f4b71Sopenharmony_ci 2627e41f4b71Sopenharmony_ci恢复被回收的卡片,并将它的状态更新为不可回收,如果卡片未被回收则只更新状态为不可回收。使用Promise异步回调。 2628e41f4b71Sopenharmony_ci 2629e41f4b71Sopenharmony_ci**模型约束:** 此接口仅可在Stage模型下使用。 2630e41f4b71Sopenharmony_ci 2631e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.REQUIRE_FORM 2632e41f4b71Sopenharmony_ci 2633e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Ability.Form 2634e41f4b71Sopenharmony_ci 2635e41f4b71Sopenharmony_ci**参数:** 2636e41f4b71Sopenharmony_ci 2637e41f4b71Sopenharmony_ci| 参数名 | 类型 | 必填 | 说明 | 2638e41f4b71Sopenharmony_ci| ------- | ------------------- | ---- | -------------- | 2639e41f4b71Sopenharmony_ci| formIds | Array<string> | 是 | 卡片标识数组。 | 2640e41f4b71Sopenharmony_ci 2641e41f4b71Sopenharmony_ci**返回值:** 2642e41f4b71Sopenharmony_ci 2643e41f4b71Sopenharmony_ci| 类型 | 说明 | 2644e41f4b71Sopenharmony_ci| ------------------- | ------------------------- | 2645e41f4b71Sopenharmony_ci| Promise<void> | 无返回结果的Promise对象。 | 2646e41f4b71Sopenharmony_ci 2647e41f4b71Sopenharmony_ci 2648e41f4b71Sopenharmony_ci**错误码:** 2649e41f4b71Sopenharmony_ci 2650e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 | 2651e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ | 2652e41f4b71Sopenharmony_ci| 201 | Permissions denied. | 2653e41f4b71Sopenharmony_ci| 202 | The application is not a system application. | 2654e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. | 2655e41f4b71Sopenharmony_ci| 16500050 | IPC connection error. | 2656e41f4b71Sopenharmony_ci| 16500060 | Service connection error. | 2657e41f4b71Sopenharmony_ci| 16501000 | An internal functional error occurred. | 2658e41f4b71Sopenharmony_ci 2659e41f4b71Sopenharmony_ci以上错误码的详细介绍请参见[卡片错误码](errorcode-form.md)。 2660e41f4b71Sopenharmony_ci 2661e41f4b71Sopenharmony_ci**示例:** 2662e41f4b71Sopenharmony_ci 2663e41f4b71Sopenharmony_ci```ts 2664e41f4b71Sopenharmony_ciimport { formHost } from '@kit.FormKit'; 2665e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 2666e41f4b71Sopenharmony_ci 2667e41f4b71Sopenharmony_citry { 2668e41f4b71Sopenharmony_ci let formIds: string[] = ['12400633174999288']; 2669e41f4b71Sopenharmony_ci formHost.recoverForms(formIds).then(() => { 2670e41f4b71Sopenharmony_ci console.info('recover forms success'); 2671e41f4b71Sopenharmony_ci }).catch((err: BusinessError) => { 2672e41f4b71Sopenharmony_ci console.error(`formHost recover forms error, code: ${err.code}, message: ${err.message}`); 2673e41f4b71Sopenharmony_ci }); 2674e41f4b71Sopenharmony_ci} catch (e) { 2675e41f4b71Sopenharmony_ci console.info(`catch error, code: ${e.code}, message: ${e.message}`); 2676e41f4b71Sopenharmony_ci} 2677e41f4b71Sopenharmony_ci``` 2678e41f4b71Sopenharmony_ci## recycleForms<sup>12+</sup> 2679e41f4b71Sopenharmony_ci 2680e41f4b71Sopenharmony_cirecycleForms(formIds: Array<string>): Promise<void> 2681e41f4b71Sopenharmony_ci 2682e41f4b71Sopenharmony_ci立即回收卡片内存。使用Promise异步回调。 2683e41f4b71Sopenharmony_ci 2684e41f4b71Sopenharmony_ci**模型约束:** 此接口仅可在Stage模型下使用。 2685e41f4b71Sopenharmony_ci 2686e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.REQUIRE_FORM 2687e41f4b71Sopenharmony_ci 2688e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Ability.Form 2689e41f4b71Sopenharmony_ci 2690e41f4b71Sopenharmony_ci**参数:** 2691e41f4b71Sopenharmony_ci 2692e41f4b71Sopenharmony_ci| 参数名 | 类型 | 必填 | 说明 | 2693e41f4b71Sopenharmony_ci| ------- | ------------------- | ---- | -------------- | 2694e41f4b71Sopenharmony_ci| formIds | Array<string> | 是 | 卡片标识数组。 | 2695e41f4b71Sopenharmony_ci 2696e41f4b71Sopenharmony_ci**返回值:** 2697e41f4b71Sopenharmony_ci 2698e41f4b71Sopenharmony_ci| 类型 | 说明 | 2699e41f4b71Sopenharmony_ci| ------------------- | ------------------------- | 2700e41f4b71Sopenharmony_ci| Promise<void> | 无返回结果的Promise对象。 | 2701e41f4b71Sopenharmony_ci 2702e41f4b71Sopenharmony_ci 2703e41f4b71Sopenharmony_ci**错误码:** 2704e41f4b71Sopenharmony_ci 2705e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 | 2706e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ | 2707e41f4b71Sopenharmony_ci| 201 | Permissions denied. | 2708e41f4b71Sopenharmony_ci| 202 | The application is not a system application. | 2709e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. | 2710e41f4b71Sopenharmony_ci| 16500050 | IPC connection error. | 2711e41f4b71Sopenharmony_ci| 16500060 | Service connection error. | 2712e41f4b71Sopenharmony_ci| 16501000 | An internal functional error occurred. | 2713e41f4b71Sopenharmony_ci 2714e41f4b71Sopenharmony_ci以上错误码的详细介绍请参见[卡片错误码](errorcode-form.md)。 2715e41f4b71Sopenharmony_ci 2716e41f4b71Sopenharmony_ci**示例:** 2717e41f4b71Sopenharmony_ci 2718e41f4b71Sopenharmony_ci```ts 2719e41f4b71Sopenharmony_ciimport { formHost } from '@kit.FormKit'; 2720e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 2721e41f4b71Sopenharmony_ci 2722e41f4b71Sopenharmony_citry { 2723e41f4b71Sopenharmony_ci let formIds: string[] = ['12400633174999288']; 2724e41f4b71Sopenharmony_ci formHost.recycleForms(formIds).then(() => { 2725e41f4b71Sopenharmony_ci console.info('recycle forms success'); 2726e41f4b71Sopenharmony_ci }).catch((err: BusinessError) => { 2727e41f4b71Sopenharmony_ci console.error(`formHost recycle forms error, code: ${err.code}, message: ${err.message}`); 2728e41f4b71Sopenharmony_ci }); 2729e41f4b71Sopenharmony_ci} catch (e) { 2730e41f4b71Sopenharmony_ci console.error(`catch error, code: ${e.code}, message: ${e.message}`); 2731e41f4b71Sopenharmony_ci} 2732e41f4b71Sopenharmony_ci``` 2733e41f4b71Sopenharmony_ci 2734e41f4b71Sopenharmony_ci## updateFormLocation<sup>12+</sup> 2735e41f4b71Sopenharmony_ciupdateFormLocation(formId: string, location: formInfo.FormLocation): void; 2736e41f4b71Sopenharmony_ci 2737e41f4b71Sopenharmony_ci更新卡片位置。 2738e41f4b71Sopenharmony_ci 2739e41f4b71Sopenharmony_ci**模型约束**: 此接口仅可在Stage模型下使用。 2740e41f4b71Sopenharmony_ci 2741e41f4b71Sopenharmony_ci**需要权限**:ohos.permission.REQUIRE_FORM 2742e41f4b71Sopenharmony_ci 2743e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Ability.Form 2744e41f4b71Sopenharmony_ci 2745e41f4b71Sopenharmony_ci**参数:** 2746e41f4b71Sopenharmony_ci 2747e41f4b71Sopenharmony_ci| 参数名 | 类型 | 必填 | 说明 | 2748e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ------- | 2749e41f4b71Sopenharmony_ci| formId | string | 是 | 卡片标识。 | 2750e41f4b71Sopenharmony_ci| location |[formInfo.FormLocation](js-apis-app-form-formInfo-sys.md#formlocation) | 是 | 卡片位置。 | 2751e41f4b71Sopenharmony_ci 2752e41f4b71Sopenharmony_ci**错误码:** 2753e41f4b71Sopenharmony_ci 2754e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 | 2755e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ | 2756e41f4b71Sopenharmony_ci| 201 | Permissions denied. | 2757e41f4b71Sopenharmony_ci| 202 | The application is not a system application. | 2758e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. | 2759e41f4b71Sopenharmony_ci| 16500050 | IPC connection error. | 2760e41f4b71Sopenharmony_ci| 16500060 | Service connection error. | 2761e41f4b71Sopenharmony_ci| 16501000 | An internal functional error occurred. | 2762e41f4b71Sopenharmony_ci| 16501001 | The ID of the form to be operated does not exist. | 2763e41f4b71Sopenharmony_ci| 16501003 | The form cannot be operated by the current application. | 2764e41f4b71Sopenharmony_ci 2765e41f4b71Sopenharmony_ci以上错误码的详细介绍请参见[卡片错误码](errorcode-form.md)。 2766e41f4b71Sopenharmony_ci 2767e41f4b71Sopenharmony_ci**示例:** 2768e41f4b71Sopenharmony_ci 2769e41f4b71Sopenharmony_ci```ts 2770e41f4b71Sopenharmony_ciimport { formHost, formInfo } from '@kit.FormKit'; 2771e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 2772e41f4b71Sopenharmony_ci 2773e41f4b71Sopenharmony_citry { 2774e41f4b71Sopenharmony_ci let formId: string = '12400633174999288'; 2775e41f4b71Sopenharmony_ci formHost.updateFormLocation(formId, formInfo.FormLocation.SCREEN_LOCK); 2776e41f4b71Sopenharmony_ci} catch (error) { 2777e41f4b71Sopenharmony_ci console.error(`catch error, code: ${(error as BusinessError).code}, message: ${(error as BusinessError).message}`); 2778e41f4b71Sopenharmony_ci} 2779e41f4b71Sopenharmony_ci``` 2780e41f4b71Sopenharmony_ci 2781e41f4b71Sopenharmony_ci## setPublishFormResult<sup>12+</sup> 2782e41f4b71Sopenharmony_ci 2783e41f4b71Sopenharmony_cisetPublishFormResult(formId: string, result: formInfo.PublishFormResult): void; 2784e41f4b71Sopenharmony_ci 2785e41f4b71Sopenharmony_ci设置卡片加桌结果。 2786e41f4b71Sopenharmony_ci 2787e41f4b71Sopenharmony_ci**模型约束**: 此接口仅可在Stage模型下使用。 2788e41f4b71Sopenharmony_ci 2789e41f4b71Sopenharmony_ci**需要权限**:ohos.permission.REQUIRE_FORM 2790e41f4b71Sopenharmony_ci 2791e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Ability.Form 2792e41f4b71Sopenharmony_ci 2793e41f4b71Sopenharmony_ci**参数:** 2794e41f4b71Sopenharmony_ci 2795e41f4b71Sopenharmony_ci| 参数名 | 类型 | 必填 | 说明 | 2796e41f4b71Sopenharmony_ci| ------ | ------------------------------------------------------------ | ---- | ------------------ | 2797e41f4b71Sopenharmony_ci| formId | string | 是 | 卡片标识。 | 2798e41f4b71Sopenharmony_ci| result | [PublishFormResult](js-apis-app-form-formInfo-sys.md#publishformresult) | 是 | 发布卡片加桌结果。 | 2799e41f4b71Sopenharmony_ci 2800e41f4b71Sopenharmony_ci**错误码:** 2801e41f4b71Sopenharmony_ci 2802e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 | 2803e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ | 2804e41f4b71Sopenharmony_ci| 201 | Permissions denied. | 2805e41f4b71Sopenharmony_ci| 202 | The application is not a system application. | 2806e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. | 2807e41f4b71Sopenharmony_ci| 16500050 | IPC connection error. | 2808e41f4b71Sopenharmony_ci| 16500060 | Service connection error. | 2809e41f4b71Sopenharmony_ci| 16501000 | An internal functional error occurred. | 2810e41f4b71Sopenharmony_ci| 16501001 | The ID of the form to be operated does not exist. | 2811e41f4b71Sopenharmony_ci 2812e41f4b71Sopenharmony_ci以上错误码的详细介绍请参见[卡片错误码](errorcode-form.md)。 2813e41f4b71Sopenharmony_ci 2814e41f4b71Sopenharmony_ci**示例:** 2815e41f4b71Sopenharmony_ci 2816e41f4b71Sopenharmony_ci```ts 2817e41f4b71Sopenharmony_ciimport { formHost, formInfo } from '@kit.FormKit'; 2818e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 2819e41f4b71Sopenharmony_ci 2820e41f4b71Sopenharmony_citry { 2821e41f4b71Sopenharmony_ci let formId: string = '12400633174999288'; 2822e41f4b71Sopenharmony_ci let res: formInfo.PublishFormResult = {code: formInfo.PublishFormErrorCode.SUCCESS, message: ''}; 2823e41f4b71Sopenharmony_ci formHost.setPublishFormResult(formId, res); 2824e41f4b71Sopenharmony_ci} catch (error) { 2825e41f4b71Sopenharmony_ci console.error(`catch error, code: ${(error as BusinessError).code}, message: ${(error as BusinessError).message}`); 2826e41f4b71Sopenharmony_ci} 2827e41f4b71Sopenharmony_ci``` 2828