formHost模块提供了卡片使用方相关接口的能力,包括对使用方同一用户下安装的卡片进行删除、释放、请求更新、获取卡片信息、状态等操作。
说明:
本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 本模块接口均为系统接口。
导入模块
import formHost from '@ohos.app.form.formHost';
deleteForm
deleteForm(formId: string, callback: AsyncCallback<void>): void
删除指定的卡片。调用此方法后,应用程序将无法使用该卡片,卡片管理器服务不再保留有关该卡片的信息。使用callback异步回调。
需要权限:ohos.permission.REQUIRE_FORM
系统能力:SystemCapability.Ability.Form
参数:
参数名 | 类型 | 必填 | 说明 |
---|---|---|---|
formId | string | 是 | 卡片标识。 |
callback | AsyncCallback<void> | 是 | 回调函数。当删除指定的卡片成功,error为undefined,否则为错误对象 |
错误码:
错误码ID | 错误信息 |
---|---|
201 | Permissions denied. |
202 | The application is not a system application. |
401 | If the input parameter is not valid parameter. |
16500050 | An IPC connection error happened. |
16500060 | A service connection error happened, please try again later. |
16501000 | An internal functional error occurred. |
16501001 | The ID of the form to be operated does not exist. |
16501003 | The form can not be operated by the current application. |
以上错误码的详细介绍请参见卡片错误码。
示例:
import formHost from '@ohos.app.form.formHost';
import Base from '@ohos.base';
try {
let formId: string = '12400633174999288';
formHost.deleteForm(formId, (error: Base.BusinessError) => {
if (error) {
console.error(`error, code: ${error.code}, message: ${error.message}`);
} else {
console.log('formHost deleteForm success');
}
});
} catch (error) {
console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message}`);
}
deleteForm
deleteForm(formId: string): Promise<void>
删除指定的卡片。调用此方法后,应用程序将无法使用该卡片,卡片管理器服务不再保留有关该卡片的信息。使用Promise异步回调。
需要权限:ohos.permission.REQUIRE_FORM
系统能力:SystemCapability.Ability.Form
参数:
参数名 | 类型 | 必填 | 说明 |
---|---|---|---|
formId | string | 是 | 卡片标识。 |
返回值:
类型 | 说明 |
---|---|
Promise<void> | 无返回结果的Promise对象。 |
错误码:
错误码ID | 错误信息 |
---|---|
201 | Permissions denied. |
202 | The application is not a system application. |
401 | If the input parameter is not valid parameter. |
16500050 | An IPC connection error happened. |
16500060 | A service connection error happened, please try again later. |
16501000 | An internal functional error occurred. |
16501001 | The ID of the form to be operated does not exist. |
16501003 | The form can not be operated by the current application. |
以上错误码的详细介绍请参见卡片错误码。
参数:
import formHost from '@ohos.app.form.formHost';
import Base from '@ohos.base';
try {
let formId: string = '12400633174999288';
formHost.deleteForm(formId).then(() => {
console.log('formHost deleteForm success');
}).catch((error: Base.BusinessError) => {
console.error(`formHost deleteForm, error: ${JSON.stringify(error)}`);
});
} catch(error) {
console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message}`);
}
releaseForm
releaseForm(formId: string, callback: AsyncCallback<void>): void
释放指定的卡片。调用此方法后,应用程序将无法使用该卡片,但卡片管理器服务仍然保留有关该卡片的缓存信息和存储信息。使用callback异步回调。
需要权限:ohos.permission.REQUIRE_FORM
系统能力:SystemCapability.Ability.Form
参数:
参数名 | 类型 | 必填 | 说明 |
---|---|---|---|
formId | string | 是 | 卡片标识。 |
callback | AsyncCallback<void> | 是 | 回调函数。当释放指定的卡片成功,error为undefined;否则为错误对象。 |
错误码:
错误码ID | 错误信息 |
---|---|
201 | Permissions denied. |
202 | The application is not a system application. |
401 | If the input parameter is not valid parameter. |
16500050 | An IPC connection error happened. |
16500060 | A service connection error happened, please try again later. |
16501000 | An internal functional error occurred. |
16501001 | The ID of the form to be operated does not exist. |
16501003 | The form can not be operated by the current application. |
以上错误码的详细介绍请参见卡片错误码。
示例:
import formHost from '@ohos.app.form.formHost';
import Base from '@ohos.base';
try {
let formId: string = '12400633174999288';
formHost.releaseForm(formId, (error: Base.BusinessError) => {
if (error) {
console.error(`error, code: ${error.code}, message: ${error.message}`);
}
});
} catch(error) {
console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message}`);
}
releaseForm
releaseForm(formId: string, isReleaseCache: boolean, callback: AsyncCallback<void>): void
释放指定的卡片。调用此方法后,应用程序将无法使用该卡片,卡片管理器服务保留有关该卡片的存储信息,可以选择是否保留缓存信息。使用callback异步回调。
需要权限:ohos.permission.REQUIRE_FORM
系统能力:SystemCapability.Ability.Form
参数:
参数名 | 类型 | 必填 | 说明 |
---|---|---|---|
formId | string | 是 | 卡片标识。 |
isReleaseCache | boolean | 是 | 是否释放缓存。 |
callback | AsyncCallback<void> | 是 | 回调函数。当释放指定的卡片成功,error为undefined;否则为错误对象。 |
错误码:
错误码ID | 错误信息 |
---|---|
201 | Permissions denied. |
202 | The application is not a system application. |
401 | If the input parameter is not valid parameter. |
16500050 | An IPC connection error happened. |
16500060 | A service connection error happened, please try again later. |
16501000 | An internal functional error occurred. |
16501001 | The ID of the form to be operated does not exist. |
16501003 | The form can not be operated by the current application. |
以上错误码的详细介绍请参见卡片错误码。
示例:
import formHost from '@ohos.app.form.formHost';
import Base from '@ohos.base';
try {
let formId: string = '12400633174999288';
formHost.releaseForm(formId, true, (error: Base.BusinessError) => {
if (error) {
console.error(`error, code: ${error.code}, message: ${error.message}`);
}
});
} catch(error) {
console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message}`);
}
releaseForm
releaseForm(formId: string, isReleaseCache?: boolean): Promise<void>
释放指定的卡片。调用此方法后,应用程序将无法使用该卡片,卡片管理器服务保留有关该卡片的存储信息,可以选择是否保留缓存信息。使用Promise异步回调。
需要权限:ohos.permission.REQUIRE_FORM
系统能力:SystemCapability.Ability.Form
参数:
参数名 | 类型 | 必填 | 说明 |
---|---|---|---|
formId | string | 是 | 卡片标识。 |
isReleaseCache | boolean | 否 | 是否释放缓存,默认为false。 |
返回值:
类型 | 说明 |
---|---|
Promise<void> | 无返回结果的Promise对象。 |
错误码:
错误码ID | 错误信息 |
---|---|
201 | Permissions denied. |
202 | The application is not a system application. |
401 | If the input parameter is not valid parameter. |
16500050 | An IPC connection error happened. |
16500060 | A service connection error happened, please try again later. |
16501000 | An internal functional error occurred. |
16501001 | The ID of the form to be operated does not exist. |
16501003 | The form can not be operated by the current application. |
以上错误码的详细介绍请参见卡片错误码。
示例:
import formHost from '@ohos.app.form.formHost';
import Base from '@ohos.base';
try {
let formId: string = '12400633174999288';
formHost.releaseForm(formId, true).then(() => {
console.log('formHost releaseForm success');
}).catch((error: Base.BusinessError) => {
console.error(`error, code: ${error.code}, message: ${error.message}`);
});
} catch(error) {
console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message}`);
}
requestForm
requestForm(formId: string, callback: AsyncCallback<void>): void
请求卡片更新。使用callback异步回调。
需要权限:ohos.permission.REQUIRE_FORM
系统能力:SystemCapability.Ability.Form
参数:
参数名 | 类型 | 必填 | 说明 |
---|---|---|---|
formId | string | 是 | 卡片标识。 |
callback | AsyncCallback<void> | 是 | 回调函数。当请求卡片更新成功,error为undefined;否则为错误对象。 |
错误码:
错误码ID | 错误信息 |
---|---|
201 | Permissions denied. |
202 | The application is not a system application. |
401 | If the input parameter is not valid parameter. |
16500050 | An IPC connection error happened. |
16500060 | A service connection error happened, please try again later. |
16501000 | An internal functional error occurred. |
16501001 | The ID of the form to be operated does not exist. |
16501003 | The form can not be operated by the current application. |
以上错误码的详细介绍请参见卡片错误码。
示例:
import formHost from '@ohos.app.form.formHost';
import Base from '@ohos.base';
try {
let formId: string = '12400633174999288';
formHost.requestForm(formId, (error: Base.BusinessError) => {
if (error) {
console.error(`error, code: ${error.code}, message: ${error.message}`);
}
});
} catch(error) {
console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message}`);
}
requestForm
requestForm(formId: string): Promise<void>
请求卡片更新。使用Promise异步回调。
需要权限:ohos.permission.REQUIRE_FORM
系统能力:SystemCapability.Ability.Form
参数:
参数名 | 类型 | 必填 | 说明 |
---|---|---|---|
formId | string | 是 | 卡片标识。 |
返回值:
类型 | 说明 |
---|---|
Promise<void> | 无返回结果的Promise对象。 |
错误码:
错误码ID | 错误信息 |
---|---|
201 | Permissions denied. |
202 | The application is not a system application. |
401 | If the input parameter is not valid parameter. |
16500050 | An IPC connection error happened. |
16500060 | A service connection error happened, please try again later. |
16501000 | An internal functional error occurred. |
16501001 | The ID of the form to be operated does not exist. |
16501003 | The form can not be operated by the current application. |
以上错误码的详细介绍请参见卡片错误码。
示例:
import formHost from '@ohos.app.form.formHost';
import Base from '@ohos.base';
try {
let formId: string = '12400633174999288';
formHost.requestForm(formId).then(() => {
console.log('formHost requestForm success');
}).catch((error: Base.BusinessError) => {
console.error(`error, code: ${error.code}, message: ${error.message}`);
});
} catch(error) {
console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message}`);
}
castToNormalForm
castToNormalForm(formId: string, callback: AsyncCallback<void>): void
将指定的临时卡片转换为普通卡片。使用callback异步回调。
需要权限:ohos.permission.REQUIRE_FORM
系统能力:SystemCapability.Ability.Form
参数:
参数名 | 类型 | 必填 | 说明 |
---|---|---|---|
formId | string | 是 | 卡片标识。 |
callback | AsyncCallback<void> | 是 | 回调函数。当将指定的临时卡片转换为普通卡片成功,error为undefined,否则为错误对象。 |
错误码:
错误码ID | 错误信息 |
---|---|
201 | Permissions denied. |
202 | The application is not a system application. |
401 | If the input parameter is not valid parameter. |
16500050 | An IPC connection error happened. |
16501000 | An internal functional error occurred. |
16501001 | The ID of the form to be operated does not exist. |
16501002 | The number of forms exceeds upper bound. |
16501003 | The form can not be operated by the current application. |
以上错误码的详细介绍请参见卡片错误码。
示例:
import formHost from '@ohos.app.form.formHost';
import Base from '@ohos.base';
try {
let formId: string = '12400633174999288';
formHost.castToNormalForm(formId, (error: Base.BusinessError) => {
if (error) {
console.error(`error, code: ${error.code}, message: ${error.message}`);
}
});
} catch(error) {
console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message}`);
}
castToNormalForm
castToNormalForm(formId: string): Promise<void>
将指定的临时卡片转换为普通卡片。使用Promise异步回调。
需要权限:ohos.permission.REQUIRE_FORM
系统能力:SystemCapability.Ability.Form
参数:
参数名 | 类型 | 必填 | 说明 |
---|---|---|---|
formId | string | 是 | 卡片标识。 |
返回值:
类型 | 说明 |
---|---|
Promise<void> | 无返回结果的Promise对象。 |
错误码:
错误码ID | 错误信息 |
---|---|
201 | Permissions denied. |
202 | The application is not a system application. |
401 | If the input parameter is not valid parameter. |
16500050 | An IPC connection error happened. |
16501000 | An internal functional error occurred. |
16501001 | The ID of the form to be operated does not exist. |
16501002 | The number of forms exceeds upper bound. |
16501003 | The form can not be operated by the current application. |
以上错误码的详细介绍请参见卡片错误码。
示例:
import formHost from '@ohos.app.form.formHost';
import Base from '@ohos.base';
try {
let formId: string = '12400633174999288';
formHost.castToNormalForm(formId).then(() => {
console.log('formHost castTempForm success');
}).catch((error: Base.BusinessError) => {
console.error(`error, code: ${error.code}, message: ${error.message}`);
});
} catch(error) {
console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message}`);
}
notifyVisibleForms
notifyVisibleForms(formIds: Array<string>, callback: AsyncCallback<void>): void
向卡片框架发送通知以使指定的卡片可见。该方法调用成功后,会调用onVisibilityChange通知卡片提供方。使用callback异步回调。
需要权限:ohos.permission.REQUIRE_FORM
系统能力:SystemCapability.Ability.Form
参数:
参数名 | 类型 | 必填 | 说明 |
---|---|---|---|
formIds | Array<string> | 是 | 卡片标识列表。 |
callback | AsyncCallback<void> | 是 | 回调函数。当向卡片框架发送通知以使指定的卡片可见成功,error为undefined,否则为错误对象。 |
错误码:
错误码ID | 错误信息 |
---|---|
201 | Permissions denied. |
202 | The application is not a system application. |
401 | If the input parameter is not valid parameter. |
16500050 | An IPC connection error happened. |
16500060 | A service connection error happened, please try again later. |
16501000 | An internal functional error occurred. |
以上错误码的详细介绍请参见卡片错误码。
示例:
import formHost from '@ohos.app.form.formHost';
import Base from '@ohos.base';
try {
let formId: string[] = ['12400633174999288'];
formHost.notifyVisibleForms(formId, (error: Base.BusinessError) => {
if (error) {
console.error(`error, code: ${error.code}, message: ${error.message}`);
}
});
} catch(error) {
console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message}`);
}
notifyVisibleForms
notifyVisibleForms(formIds: Array<string>): Promise<void>
向卡片框架发送通知以使指定的卡片可见。该方法调用成功后,会调用onVisibilityChange通知卡片提供方。使用Promise异步回调。
需要权限:ohos.permission.REQUIRE_FORM
系统能力:SystemCapability.Ability.Form
参数:
参数名 | 类型 | 必填 | 说明 |
---|---|---|---|
formIds | Array<string> | 是 | 卡片标识列表。 |
返回值:
类型 | 说明 |
---|---|
Promise<void> | 无返回结果的Promise对象。 |
错误码:
错误码ID | 错误信息 |
---|---|
201 | Permissions denied. |
202 | The application is not a system application. |
401 | If the input parameter is not valid parameter. |
16500050 | An IPC connection error happened. |
16500060 | A service connection error happened, please try again later. |
16501000 | An internal functional error occurred. |
以上错误码的详细介绍请参见卡片错误码。
示例:
import formHost from '@ohos.app.form.formHost';
import Base from '@ohos.base';
try {
let formId: string[] = ['12400633174999288'];
formHost.notifyVisibleForms(formId).then(() => {
console.log('formHost notifyVisibleForms success');
}).catch((error: Base.BusinessError) => {
console.error(`error, code: ${error.code}, message: ${error.message}`);
});
} catch(error) {
console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message}`);
}
notifyInvisibleForms
notifyInvisibleForms(formIds: Array<string>, callback: AsyncCallback<void>): void
向卡片框架发送通知以使指定的卡片不可见。该方法调用成功后,会调用onVisibilityChange通知卡片提供方。使用callback异步回调。
需要权限:ohos.permission.REQUIRE_FORM
系统能力:SystemCapability.Ability.Form
参数:
参数名 | 类型 | 必填 | 说明 |
---|---|---|---|
formIds | Array<string> | 是 | 卡片标识列表。 |
callback | AsyncCallback<void> | 是 | 回调函数。当向卡片框架发送通知以使指定的卡片不可见成功,error为undefined,否则为错误对象。 |
错误码:
错误码ID | 错误信息 |
---|---|
201 | Permissions denied. |
202 | The application is not a system application. |
401 | If the input parameter is not valid parameter. |
16500050 | An IPC connection error happened. |
16500060 | A service connection error happened, please try again later. |
16501000 | An internal functional error occurred. |
以上错误码的详细介绍请参见卡片错误码。
示例:
import formHost from '@ohos.app.form.formHost';
import Base from '@ohos.base';
try {
let formId: string[] = ['12400633174999288'];
formHost.notifyInvisibleForms(formId, (error: Base.BusinessError) => {
if (error) {
console.error(`error, code: ${error.code}, message: ${error.message}`);
}
});
} catch(error) {
console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message}`);
}
notifyInvisibleForms
notifyInvisibleForms(formIds: Array<string>): Promise<void>
向卡片框架发送通知以使指定的卡片不可见。该方法调用成功后,会调用onVisibilityChange通知卡片提供方。使用Promise异步回调。
需要权限:ohos.permission.REQUIRE_FORM
系统能力:SystemCapability.Ability.Form
参数:
参数名 | 类型 | 必填 | 说明 |
---|---|---|---|
formIds | Array<string> | 是 | 卡片标识列表。 |
返回值:
类型 | 说明 |
---|---|
Promise<void> | 无返回结果的Promise对象。 |
错误码:
错误码ID | 错误信息 |
---|---|
201 | Permissions denied. |
202 | The application is not a system application. |
401 | If the input parameter is not valid parameter. |
16500050 | An IPC connection error happened. |
16500060 | A service connection error happened, please try again later. |
16501000 | An internal functional error occurred. |
以上错误码的详细介绍请参见卡片错误码。
示例:
import formHost from '@ohos.app.form.formHost';
import Base from '@ohos.base';
try {
let formId: string[] = ['12400633174999288'];
formHost.notifyInvisibleForms(formId).then(() => {
console.log('formHost notifyInvisibleForms success');
}).catch((error: Base.BusinessError) => {
console.error(`error, code: ${error.code}, message: ${error.message}`);
});
} catch(error) {
console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message}`);
}
enableFormsUpdate
enableFormsUpdate(formIds: Array<string>, callback: AsyncCallback<void>): void
向卡片框架发送通知以使指定的卡片可以更新。该方法调用成功后,卡片刷新状态设置为使能,卡片可以接收来自卡片提供方的更新。使用callback异步回调。
需要权限:ohos.permission.REQUIRE_FORM
系统能力:SystemCapability.Ability.Form
参数:
参数名 | 类型 | 必填 | 说明 |
---|---|---|---|
formIds | Array<string> | 是 | 卡片标识列表。 |
callback | AsyncCallback<void> | 是 | 回调函数。当向卡片框架发送通知以使指定的卡片可以更新成功,error为undefined,否则为错误对象。 |
错误码:
错误码ID | 错误信息 |
---|---|
201 | Permissions denied. |
202 | The application is not a system application. |
401 | If the input parameter is not valid parameter. |
16500050 | An IPC connection error happened. |
16500060 | A service connection error happened, please try again later. |
16501000 | An internal functional error occurred. |
16501003 | The form can not be operated by the current application. |
以上错误码的详细介绍请参见卡片错误码。
示例:
import formHost from '@ohos.app.form.formHost';
import Base from '@ohos.base';
try {
let formId: string[] = ['12400633174999288'];
formHost.enableFormsUpdate(formId, (error: Base.BusinessError) => {
if (error) {
console.error(`error, code: ${error.code}, message: ${error.message}`);
}
});
} catch(error) {
console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message}`);
}
enableFormsUpdate
enableFormsUpdate(formIds: Array<string>): Promise<void>
向卡片框架发送通知以使指定的卡片可以更新。该方法调用成功后,卡片刷新状态设置为使能,卡片可以接收来自卡片提供方的更新。使用Promise异步回调。
需要权限:ohos.permission.REQUIRE_FORM
系统能力:SystemCapability.Ability.Form
参数:
参数名 | 类型 | 必填 | 说明 |
---|---|---|---|
formIds | Array<string> | 是 | 卡片标识列表。 |
返回值:
类型 | 说明 |
---|---|
Promise<void> | 无返回结果的Promise对象。 |
错误码:
错误码ID | 错误信息 |
---|---|
201 | Permissions denied. |
202 | The application is not a system application. |
401 | If the input parameter is not valid parameter. |
16500050 | An IPC connection error happened. |
16500060 | A service connection error happened, please try again later. |
16501000 | An internal functional error occurred. |
16501003 | The form can not be operated by the current application. |
以上错误码的详细介绍请参见卡片错误码。
示例:
import formHost from '@ohos.app.form.formHost';
import Base from '@ohos.base';
try {
let formId: string[] = ['12400633174999288'];
formHost.enableFormsUpdate(formId).then(() => {
console.log('formHost enableFormsUpdate success');
}).catch((error: Base.BusinessError) => {
console.error(`error, code: ${error.code}, message: ${error.message}`);
});
} catch(error) {
console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message}`);
}
disableFormsUpdate
disableFormsUpdate(formIds: Array<string>, callback: AsyncCallback<void>): void
向卡片框架发送通知以使指定的卡片不可以更新。该方法调用成功后,卡片刷新状态设置为去使能,卡片不可以接收来自卡片提供方的更新。使用callback异步回调。
需要权限:ohos.permission.REQUIRE_FORM
系统能力:SystemCapability.Ability.Form
参数:
参数名 | 类型 | 必填 | 说明 |
---|---|---|---|
formIds | Array<string> | 是 | 卡片标识列表。 |
callback | AsyncCallback<void> | 是 | 回调函数。当向卡片框架发送通知以使指定的卡片不可以更新成功,error为undefined,否则为错误对象。 |
错误码:
错误码ID | 错误信息 |
---|---|
201 | Permissions denied. |
202 | The application is not a system application. |
401 | If the input parameter is not valid parameter. |
16500050 | An IPC connection error happened. |
16500060 | A service connection error happened, please try again later. |
16501000 | An internal functional error occurred. |
16501001 | The ID of the form to be operated does not exist. |
16501003 | The form can not be operated by the current application. |
以上错误码的详细介绍请参见卡片错误码。
示例:
import formHost from '@ohos.app.form.formHost';
import Base from '@ohos.base';
try {
let formId: string[] = ['12400633174999288'];
formHost.disableFormsUpdate(formId, (error: Base.BusinessError) => {
if (error) {
console.error(`error, code: ${error.code}, message: ${error.message}`);
}
});
} catch(error) {
console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message}`);
}
disableFormsUpdate
disableFormsUpdate(formIds: Array<string>): Promise<void>
向卡片框架发送通知以使指定的卡片不可以更新。该方法调用成功后,卡片刷新状态设置为去使能,卡片不可以接收来自卡片提供方的更新。使用Promise异步回调。
需要权限:ohos.permission.REQUIRE_FORM
系统能力:SystemCapability.Ability.Form
参数:
参数名 | 类型 | 必填 | 说明 |
---|---|---|---|
formIds | Array<string> | 是 | 卡片标识列表。 |
返回值:
类型 | 说明 |
---|---|
Promise<void> | 无返回结果的Promise对象。 |
错误码:
错误码ID | 错误信息 |
---|---|
201 | Permissions denied. |
202 | The application is not a system application. |
401 | If the input parameter is not valid parameter. |
16500050 | An IPC connection error happened. |
16500060 | A service connection error happened, please try again later. |
16501000 | An internal functional error occurred. |
16501001 | The ID of the form to be operated does not exist. |
16501003 | The form can not be operated by the current application. |
以上错误码的详细介绍请参见卡片错误码。
示例:
import formHost from '@ohos.app.form.formHost';
import Base from '@ohos.base';
try {
let formId: string[] = ['12400633174999288'];
formHost.disableFormsUpdate(formId).then(() => {
console.log('formHost disableFormsUpdate success');
}).catch((error: Base.BusinessError) => {
console.error(`error, code: ${error.code}, message: ${error.message}`);
});
} catch(error) {
console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message}`);
}
isSystemReady
isSystemReady(callback: AsyncCallback<void>): void
检查系统是否准备好。使用callback异步回调。
系统能力:SystemCapability.Ability.Form
参数:
参数名 | 类型 | 必填 | 说明 |
---|---|---|---|
callback | AsyncCallback<void> | 是 | 回调函数。当检查系统是否准备好成功,error为undefined,否则为错误对象。 |
错误码:
错误码ID | 错误信息 |
---|---|
202 | The application is not a system application. |
401 | If the input parameter is not valid parameter. |
以上错误码的详细介绍请参见卡片错误码。
示例:
import formHost from '@ohos.app.form.formHost';
import Base from '@ohos.base';
try {
formHost.isSystemReady((error: Base.BusinessError) => {
if (error) {
console.error(`error, code: ${error.code}, message: ${error.message}`);
}
});
} catch(error) {
console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message}`);
}
isSystemReady
isSystemReady(): Promise<void>
检查系统是否准备好。使用Promise异步回调。
系统能力:SystemCapability.Ability.Form
返回值:
类型 | 说明 |
---|---|
Promise<void> | 无返回结果的Promise对象。 |
错误码:
错误码ID | 错误信息 |
---|---|
202 | The application is not a system application. |
以上错误码的详细介绍请参见卡片错误码。
示例:
import formHost from '@ohos.app.form.formHost';
import Base from '@ohos.base';
try {
formHost.isSystemReady().then(() => {
console.log('formHost isSystemReady success');
}).catch((error: Base.BusinessError) => {
console.error(`error, code: ${error.code}, message: ${error.message}`);
});
} catch(error) {
console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message}`);
}
getAllFormsInfo
getAllFormsInfo(callback: AsyncCallback<Array<formInfo.FormInfo>>): void
获取设备上所有应用提供的卡片信息。使用callback异步回调。
需要权限:ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
系统能力:SystemCapability.Ability.Form
参数:
参数名 | 类型 | 必填 | 说明 |
---|---|---|---|
callback | AsyncCallback<Array<formInfo.FormInfo>> | 是 | 回调函数。当获取设备上所有应用提供的卡片信息成功,error为undefined,data为查询到的卡片信息;否则为错误对象。 |
错误码:
错误码ID | 错误信息 |
---|---|
201 | Permissions denied. |
202 | The application is not a system application. |
401 | If the input parameter is not valid parameter. |
16500050 | An IPC connection error happened. |
16500060 | A service connection error happened, please try again later. |
16501000 | An internal functional error occurred. |
以上错误码的详细介绍请参见卡片错误码。
示例:
import formHost from '@ohos.app.form.formHost';
import formInfo from '@ohos.app.form.formInfo';
import Base from '@ohos.base';
try {
formHost.getAllFormsInfo((error: Base.BusinessError, data: formInfo.FormInfo[]) => {
if (error) {
console.error(`error, code: ${error.code}, message: ${error.message}`);
} else {
console.log(`formHost getAllFormsInfo, data: ${JSON.stringify(data)}`);
}
});
} catch(error) {
console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message}`);
}
getAllFormsInfo
getAllFormsInfo(): Promise<Array<formInfo.FormInfo>>
获取设备上所有应用提供的卡片信息。使用Promise异步回调。
需要权限:ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
系统能力:SystemCapability.Ability.Form
返回值:
类型 | 说明 |
---|---|
Promise<Array<formInfo.FormInfo>> | Promise对象,返回查询到的卡片信息。 |
错误码:
错误码ID | 错误信息 |
---|---|
201 | Permissions denied. |
202 | The application is not a system application. |
16500050 | An IPC connection error happened. |
16500060 | A service connection error happened, please try again later. |
16501000 | An internal functional error occurred. |
以上错误码的详细介绍请参见卡片错误码。
示例:
import formHost from '@ohos.app.form.formHost';
import formInfo from '@ohos.app.form.formInfo';
import Base from '@ohos.base';
try {
formHost.getAllFormsInfo().then((data: formInfo.FormInfo[]) => {
console.log(`formHost getAllFormsInfo data: ${JSON.stringify(data)}`);
}).catch((error: Base.BusinessError) => {
console.error(`error, code: ${error.code}, message: ${error.message}`);
});
} catch(error) {
console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message}`);
}
getFormsInfo
getFormsInfo(bundleName: string, callback: AsyncCallback<Array<formInfo.FormInfo>>): void
获取设备上指定应用程序提供的卡片信息。使用callback异步回调。
需要权限:ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
系统能力:SystemCapability.Ability.Form
参数:
参数名 | 类型 | 必填 | 说明 |
---|---|---|---|
bundleName | string | 是 | 要查询的应用Bundle名称。 |
callback | AsyncCallback<Array<formInfo.FormInfo>> | 是 | 回调函数。当获取设备上指定应用程序提供的卡片信息成功,error为undefined,data为查询到的卡片信息;否则为错误对象。 |
错误码:
错误码ID | 错误信息 |
---|---|
201 | Permissions denied. |
202 | The application is not a system application. |
401 | If the input parameter is not valid parameter. |
16500050 | An IPC connection error happened. |
16500060 | A service connection error happened, please try again later. |
16500100 | Failed to obtain the configuration information. |
16501000 | An internal functional error occurred. |
以上错误码的详细介绍请参见卡片错误码。
示例:
import formHost from '@ohos.app.form.formHost';
import formInfo from '@ohos.app.form.formInfo';
import Base from '@ohos.base';
try {
formHost.getFormsInfo('com.example.ohos.formjsdemo', (error: Base.BusinessError, data: formInfo.FormInfo[]) => {
if (error) {
console.error(`error, code: ${error.code}, message: ${error.message}`);
} else {
console.log(`formHost getFormsInfo, data: ${JSON.stringify(data)}`);
}
});
} catch(error) {
console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message}`);
}
getFormsInfo
getFormsInfo(bundleName: string, moduleName: string, callback: AsyncCallback<Array<formInfo.FormInfo>>): void
获取设备上指定应用程序提供的卡片信息。使用callback异步回调。
需要权限:ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
系统能力:SystemCapability.Ability.Form
参数:
参数名 | 类型 | 必填 | 说明 |
---|---|---|---|
bundleName | string | 是 | 要查询的应用Bundle名称。 |
moduleName | string | 是 | 要查询的模块名称。 |
callback | AsyncCallback<Array<formInfo.FormInfo>> | 是 | 回调函数。当获取设备上指定应用程序提供的卡片信息成功,error为undefined,data为查询到的卡片信息;否则为错误对象。 |
错误码:
错误码ID | 错误信息 |
---|---|
201 | Permissions denied. |
202 | The application is not a system application. |
401 | If the input parameter is not valid parameter. |
16500050 | An IPC connection error happened. |
16500060 | A service connection error happened, please try again later. |
16500100 | Failed to obtain the configuration information. |
16501000 | An internal functional error occurred. |
以上错误码的详细介绍请参见卡片错误码。
示例:
import formHost from '@ohos.app.form.formHost';
import formInfo from '@ohos.app.form.formInfo';
import Base from '@ohos.base';
try {
formHost.getFormsInfo('com.example.ohos.formjsdemo', 'entry', (error: Base.BusinessError, data: formInfo.FormInfo[]) => {
if (error) {
console.error(`error, code: ${error.code}, message: ${error.message}`);
} else {
console.log('formHost getFormsInfo, data: ${JSON.stringify(data)}');
}
});
} catch(error) {
console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message}`);
}
getFormsInfo
getFormsInfo(bundleName: string, moduleName?: string): Promise<Array<formInfo.FormInfo>>
获取设备上指定应用程序提供的卡片信息。使用Promise异步回调。
需要权限:ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
系统能力:SystemCapability.Ability.Form
参数:
参数名 | 类型 | 必填 | 说明 |
---|---|---|---|
bundleName | string | 是 | 要查询的应用Bundle名称。 |
moduleName | string | 否 | 要查询的模块名称,缺省默认为空。 |
返回值:
类型 | 说明 |
---|---|
Promise<Array<formInfo.FormInfo>> | Promise对象,返回查询到的卡片信息。 |
错误码:
错误码ID | 错误信息 |
---|---|
201 | Permissions denied. |
202 | The application is not a system application. |
401 | If the input parameter is not valid parameter. |
16500050 | An IPC connection error happened. |
16500060 | A service connection error happened, please try again later. |
16500100 | Failed to obtain the configuration information. |
16501000 | An internal functional error occurred. |
以上错误码的详细介绍请参见卡片错误码。
示例:
import formHost from '@ohos.app.form.formHost';
import formInfo from '@ohos.app.form.formInfo';
import Base from '@ohos.base';
try {
formHost.getFormsInfo('com.example.ohos.formjsdemo', 'entry').then((data: formInfo.FormInfo[]) => {
console.log(`formHost getFormsInfo, data: ${JSON.stringify(data)}`);
}).catch((error: Base.BusinessError) => {
console.error(`error, code: ${error.code}, message: ${error.message}`);
});
} catch(error) {
console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message}`);
}
deleteInvalidForms
deleteInvalidForms(formIds: Array<string>, callback: AsyncCallback<number>): void
根据列表删除应用程序的无效卡片。使用callback异步回调。
需要权限:ohos.permission.REQUIRE_FORM
系统能力:SystemCapability.Ability.Form
参数:
参数名 | 类型 | 必填 | 说明 |
---|---|---|---|
formIds | Array<string> | 是 | 有效卡片标识列表。 |
callback | AsyncCallback<number> | 是 | 回调函数。当根据列表删除应用程序的无效卡片成功,error为undefined,data为删除的卡片个数;否则为错误对象。 |
错误码:
错误码ID | 错误信息 |
---|---|
201 | Permissions denied. |
202 | The application is not a system application. |
401 | If the input parameter is not valid parameter. |
16500050 | An IPC connection error happened. |
16500060 | A service connection error happened, please try again later. |
16501000 | An internal functional error occurred. |
以上错误码的详细介绍请参见卡片错误码。
示例:
import formHost from '@ohos.app.form.formHost';
import Base from '@ohos.base';
try {
let formIds: string[] = new Array('12400633174999288', '12400633174999289');
formHost.deleteInvalidForms(formIds, (error: Base.BusinessError, data: number) => {
if (error) {
console.error(`error, code: ${error.code}, message: ${error.message}`);
} else {
console.log(`formHost deleteInvalidForms, data: ${JSON.stringify(data)}`);
}
});
} catch(error) {
console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message}`);
}
deleteInvalidForms
deleteInvalidForms(formIds: Array<string>): Promise<number>
根据列表删除应用程序的无效卡片。使用Promise异步回调。
需要权限:ohos.permission.REQUIRE_FORM
系统能力:SystemCapability.Ability.Form
参数:
参数名 | 类型 | 必填 | 说明 |
---|---|---|---|
formIds | Array<string> | 是 | 有效卡片标识列表。 |
返回值:
类型 | 说明 |
---|---|
Promise<number> | Promise对象,返回删除的卡片个数。 |
错误码:
错误码ID | 错误信息 |
---|---|
201 | Permissions denied. |
202 | The application is not a system application. |
401 | If the input parameter is not valid parameter. |
16500050 | An IPC connection error happened. |
16500060 | A service connection error happened, please try again later. |
16501000 | An internal functional error occurred. |
以上错误码的详细介绍请参见卡片错误码。
示例:
import formHost from '@ohos.app.form.formHost';
import Base from '@ohos.base';
try {
let formIds: string[] = new Array('12400633174999288', '12400633174999289');
formHost.deleteInvalidForms(formIds).then((data: number) => {
console.log(`formHost deleteInvalidForms, data: ${JSON.stringify(data)}`);
}).catch((error: Base.BusinessError) => {
console.error(`error, code: ${error.code}, message: ${error.message}`);
});
} catch(error) {
console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message}`);
}
acquireFormState
acquireFormState(want: Want, callback: AsyncCallback<formInfo.FormStateInfo>): void
获取卡片状态。使用callback异步回调。
需要权限:ohos.permission.REQUIRE_FORM 和 ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
系统能力:SystemCapability.Ability.Form
参数:
参数名 | 类型 | 必填 | 说明 |
---|---|---|---|
want | Want | 是 | 查询卡片状态时携带的want信息。需要包含bundle名、ability名、module名、卡片名、卡片规格等。 |
callback | AsyncCallback<formInfo.FormStateInfo> | 是 | 回调函数。当获取卡片状态成功,error为undefined,data为获取到的卡片状态;否则为错误对象。 |
错误码:
错误码ID | 错误信息 |
---|---|
201 | Permissions denied. |
202 | The application is not a system application. |
401 | If the input parameter is not valid parameter. |
16500050 | An IPC connection error happened. |
16500060 | A service connection error happened, please try again later. |
16500100 | Failed to obtain the configuration information. |
16501000 | An internal functional error occurred. |
以上错误码的详细介绍请参见卡片错误码。
示例:
import formHost from '@ohos.app.form.formHost';
import Want from '@ohos.app.ability.Want';
import formInfo from '@ohos.app.form.formInfo';
import Base from '@ohos.base';
let want: Want = {
'deviceId': '',
'bundleName': 'ohos.samples.FormApplication',
'abilityName': 'FormAbility',
'parameters': {
'ohos.extra.param.key.module_name': 'entry',
'ohos.extra.param.key.form_name': 'widget',
'ohos.extra.param.key.form_dimension': 2
}
};
try {
formHost.acquireFormState(want, (error:Base.BusinessError, data: formInfo.FormStateInfo) => {
if (error) {
console.error(`error, code: ${error.code}, message: ${error.message}`);
} else {
console.log(`formHost acquireFormState, data: ${JSON.stringify(data)}`);
}
});
} catch(error) {
console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message}`);
}
acquireFormState
acquireFormState(want: Want): Promise<formInfo.FormStateInfo>
获取卡片状态。使用Promise异步回调。
需要权限:ohos.permission.REQUIRE_FORM 和 ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
系统能力:SystemCapability.Ability.Form
参数:
参数名 | 类型 | 必填 | 说明 |
---|---|---|---|
want | Want | 是 | 查询卡片状态时携带的want信息。需要包含bundle名、ability名、module名、卡片名、卡片规格等。 |
返回值:
类型 | 说明 |
---|---|
Promise<formInfo.FormStateInfo> | Promise对象,返回卡片状态。 |
错误码:
错误码ID | 错误信息 |
---|---|
201 | Permissions denied. |
202 | The application is not a system application. |
401 | If the input parameter is not valid parameter. |
16500050 | An IPC connection error happened. |
16500060 | A service connection error happened, please try again later. |
16500100 | Failed to obtain the configuration information. |
16501000 | An internal functional error occurred. |
以上错误码的详细介绍请参见卡片错误码。
示例:
import formHost from '@ohos.app.form.formHost';
import Want from '@ohos.app.ability.Want';
import formInfo from '@ohos.app.form.formInfo';
import Base from '@ohos.base';
let want: Want = {
'deviceId': '',
'bundleName': 'ohos.samples.FormApplication',
'abilityName': 'FormAbility',
'parameters': {
'ohos.extra.param.key.module_name': 'entry',
'ohos.extra.param.key.form_name': 'widget',
'ohos.extra.param.key.form_dimension': 2
}
};
try {
formHost.acquireFormState(want).then((data: formInfo.FormStateInfo) => {
console.log(`formHost acquireFormState, data: ${JSON.stringify(data)}`);
}).catch((error: Base.BusinessError) => {
console.error(`error, code: ${error.code}, message: ${error.message}`);
});
} catch(error) {
console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message}`);
}
on('formUninstall')
on(type: 'formUninstall', callback: Callback<string>): void
订阅卡片卸载事件。使用callback异步回调。
系统能力:SystemCapability.Ability.Form
参数:
参数名 | 类型 | 必填 | 说明 |
---|---|---|---|
type | string | 是 | 填写'formUninstall',表示卡片卸载事件。 |
callback | Callback<string> | 是 | 回调函数。返回卡片标识。 |
错误码:
错误码ID | 错误信息 |
---|---|
202 | The application is not a system application. |
401 | If the input parameter is not valid parameter. |
以上错误码的详细介绍请参见卡片错误码。
示例:
import formHost from '@ohos.app.form.formHost';
formHost.on('formUninstall', (formId: string) => {
console.log(`formHost on formUninstall, formId: ${formId}`);
});
off('formUninstall')
off(type: 'formUninstall', callback?: Callback<string>): void
取消订阅卡片卸载事件。使用callback异步回调。
系统能力:SystemCapability.Ability.Form
参数:
参数名 | 类型 | 必填 | 说明 |
---|---|---|---|
type | string | 是 | 填写'formUninstall',表示卡片卸载事件。 |
callback | Callback<string> | 否 | 回调函数。返回卡片标识。缺省时,表示注销所有已注册事件回调。 需与对应on('formUninstall')的callback一致。 |
错误码:
错误码ID | 错误信息 |
---|---|
202 | The application is not a system application. |
401 | If the input parameter is not valid parameter. |
以上错误码的详细介绍请参见卡片错误码。
示例:
import formHost from '@ohos.app.form.formHost';
formHost.off('formUninstall', (formId: string) => {
console.log(`formHost on formUninstall, formId: ${formId}`);
});
notifyFormsVisible
notifyFormsVisible(formIds: Array<string>, isVisible: boolean, callback: AsyncCallback<void>): void
通知卡片是否可见。使用callback异步回调。
需要权限:ohos.permission.REQUIRE_FORM
系统能力:SystemCapability.Ability.Form
参数:
参数名 | 类型 | 必填 | 说明 |
---|---|---|---|
formIds | Array<string> | 是 | 卡片标识列表。 |
isVisible | boolean | 是 | 是否可见。 |
callback | AsyncCallback<void> | 是 | 回调函数。当通知卡片是否可见成功,error为undefined,否则为错误对象。 |
错误码:
错误码ID | 错误信息 |
---|---|
201 | Permissions denied. |
202 | The application is not a system application. |
401 | If the input parameter is not valid parameter. |
16500050 | An IPC connection error happened. |
16500060 | A service connection error happened, please try again later. |
16501000 | An internal functional error occurred. |
16501003 | The form can not be operated by the current application. |
以上错误码的详细介绍请参见卡片错误码。
示例:
import formHost from '@ohos.app.form.formHost';
import Base from '@ohos.base';
let formIds: string[] = new Array('12400633174999288', '12400633174999289');
try {
formHost.notifyFormsVisible(formIds, true, (error: Base.BusinessError) => {
if (error) {
console.error(`error, code: ${error.code}, message: ${error.message}`);
}
});
} catch(error) {
console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message}`);
}
notifyFormsVisible
notifyFormsVisible(formIds: Array<string>, isVisible: boolean): Promise<void>
通知卡片是否可见。使用Promise异步回调。
需要权限:ohos.permission.REQUIRE_FORM
系统能力:SystemCapability.Ability.Form
参数:
参数名 | 类型 | 必填 | 说明 |
---|---|---|---|
formIds | Array<string> | 是 | 卡片标识列表。 |
isVisible | boolean | 是 | 是否可见。 |
返回值:
类型 | 说明 |
---|---|
Promise<void> | 无返回结果的Promise对象。 |
错误码:
错误码ID | 错误信息 |
---|---|
201 | Permissions denied. |
202 | The application is not a system application. |
401 | If the input parameter is not valid parameter. |
16500050 | An IPC connection error happened. |
16500060 | A service connection error happened, please try again later. |
16501000 | An internal functional error occurred. |
16501003 | The form can not be operated by the current application. |
以上错误码的详细介绍请参见卡片错误码。
示例:
import formHost from '@ohos.app.form.formHost';
import Base from '@ohos.base';
let formIds: string[] = new Array('12400633174999288', '12400633174999289');
try {
formHost.notifyFormsVisible(formIds, true).then(() => {
console.log('formHost notifyFormsVisible success');
}).catch((error: Base.BusinessError) => {
console.error(`error, code: ${error.code}, message: ${error.message}`);
});
} catch(error) {
console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message}`);
}
notifyFormsEnableUpdate
notifyFormsEnableUpdate(formIds: Array<string>, isEnableUpdate: boolean, callback: AsyncCallback<void>): void
通知卡片是否启用更新状态。使用callback异步回调。
需要权限:ohos.permission.REQUIRE_FORM
系统能力:SystemCapability.Ability.Form
参数:
参数名 | 类型 | 必填 | 说明 |
---|---|---|---|
formIds | Array<string> | 是 | 卡片标识列表。 |
isEnableUpdate | boolean | 是 | 是否使能更新。 |
callback | AsyncCallback<void> | 是 | 回调函数。当通知卡片是否启用更新状态成功,error为undefined,否则为错误对象。 |
错误码:
错误码ID | 错误信息 |
---|---|
201 | Permissions denied. |
202 | The application is not a system application. |
401 | If the input parameter is not valid parameter. |
16500050 | An IPC connection error happened. |
16500060 | A service connection error happened, please try again later. |
16501000 | An internal functional error occurred. |
16501003 | The form can not be operated by the current application. |
以上错误码的详细介绍请参见卡片错误码。
示例:
import formHost from '@ohos.app.form.formHost';
import Base from '@ohos.base';
let formIds: string[] = new Array('12400633174999288', '12400633174999289');
try {
formHost.notifyFormsEnableUpdate(formIds, true, (error: Base.BusinessError) => {
if (error) {
console.error(`error, code: ${error.code}, message: ${error.message}`);
}
});
} catch(error) {
console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message}`);
}
notifyFormsEnableUpdate
notifyFormsEnableUpdate(formIds: Array<string>, isEnableUpdate: boolean): Promise<void>
通知卡片是否启用更新状态。使用Promise异步回调。
需要权限:ohos.permission.REQUIRE_FORM
系统能力:SystemCapability.Ability.Form
参数:
参数名 | 类型 | 必填 | 说明 |
---|---|---|---|
formIds | Array<string> | 是 | 卡片标识列表。 |
isEnableUpdate | boolean | 是 | 是否使能更新。 |
返回值:
类型 | 说明 |
---|---|
Promise<void> | 无返回结果的Promise对象。 |
错误码:
错误码ID | 错误信息 |
---|---|
201 | Permissions denied. |
202 | The application is not a system application. |
401 | If the input parameter is not valid parameter. |
16500050 | An IPC connection error happened. |
16500060 | A service connection error happened, please try again later. |
16501000 | An internal functional error occurred. |
16501003 | The form can not be operated by the current application. |
以上错误码的详细介绍请参见卡片错误码。
示例:
import formHost from '@ohos.app.form.formHost';
import Base from '@ohos.base';
let formIds: string[] = new Array('12400633174999288', '12400633174999289');
try {
formHost.notifyFormsEnableUpdate(formIds, true).then(() => {
console.log('formHost notifyFormsEnableUpdate success');
}).catch((error: Base.BusinessError) => {
console.error(`error, code: ${error.code}, message: ${error.message}`);
});
} catch(error) {
console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message}`);
}
shareForm
shareForm(formId: string, deviceId: string, callback: AsyncCallback<void>): void
指定formId和远程设备Id进行卡片分享。使用callback异步回调。
需要权限:ohos.permission.REQUIRE_FORM 和 ohos.permission.DISTRIBUTED_DATASYNC
系统能力:SystemCapability.Ability.Form
参数:
参数名 | 类型 | 必填 | 说明 |
---|---|---|---|
formId | string | 是 | 卡片标识。 |
deviceId | string | 是 | 远程设备标识。 |
callback | AsyncCallback<void> | 是 | 回调函数。当指定formId和远程设备Id进行卡片分享成功,error为undefined,否则为错误对象。 |
错误码:
错误码ID | 错误信息 |
---|---|
201 | Permissions denied. |
202 | The application is not a system application. |
401 | If the input parameter is not valid parameter. |
16500050 | An IPC connection error happened. |
16501000 | An internal functional error occurred. |
16501001 | The ID of the form to be operated does not exist. |
16501003 | The form can not be operated by the current application. |
以上错误码的详细介绍请参见卡片错误码。
示例:
import formHost from '@ohos.app.form.formHost';
import Base from '@ohos.base';
let formId: string = '12400633174999288';
let deviceId: string = 'EFC11C0C53628D8CC2F8CB5052477E130D075917034613B9884C55CD22B3DEF2';
try {
formHost.shareForm(formId, deviceId, (error: Base.BusinessError) => {
if (error) {
console.error(`error, code: ${error.code}, message: ${error.message}`);
}
});
} catch(error) {
console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message}`);
}
shareForm
shareForm(formId: string, deviceId: string): Promise<void>
指定formId和远程设备Id进行卡片分享。使用Promise异步回调。
需要权限:ohos.permission.REQUIRE_FORM 和 ohos.permission.DISTRIBUTED_DATASYNC
系统能力:SystemCapability.Ability.Form
参数:
参数名 | 类型 | 必填 | 说明 |
---|---|---|---|
formId | string | 是 | 卡片标识。 |
deviceId | string | 是 | 远程设备标识。 |
返回值:
类型 | 说明 |
---|---|
Promise<void> | 无返回结果的Promise对象。 |
错误码:
错误码ID | 错误信息 |
---|---|
201 | Permissions denied. |
202 | The application is not a system application. |
401 | If the input parameter is not valid parameter. |
16500050 | An IPC connection error happened. |
16501000 | An internal functional error occurred. |
16501001 | The ID of the form to be operated does not exist. |
16501003 | The form can not be operated by the current application. |
以上错误码的详细介绍请参见卡片错误码。
示例:
import formHost from '@ohos.app.form.formHost';
import Base from '@ohos.base';
let formId: string = '12400633174999288';
let deviceId: string = 'EFC11C0C53628D8CC2F8CB5052477E130D075917034613B9884C55CD22B3DEF2';
try {
formHost.shareForm(formId, deviceId).then(() => {
console.log('formHost shareForm success');
}).catch((error: Base.BusinessError) => {
console.error(`error, code: ${error.code}, message: ${error.message}`);
});
} catch(error) {
console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message}`);
}
notifyFormsPrivacyProtected
notifyFormsPrivacyProtected(formIds: Array<string>, isProtected: boolean, callback: AsyncCallback<void>): void
通知指定卡片隐私保护状态改变。使用callback异步回调。
需要权限:ohos.permission.REQUIRE_FORM
系统能力:SystemCapability.Ability.Form
参数:
参数名 | 类型 | 必填 | 说明 |
---|---|---|---|
formIds | Array<string> | 是 | 需要修改隐私保护的卡片标识列表。 |
isProtected | boolean | 是 | 是否进行隐私保护。 |
callback | AsyncCallback<void> | 是 | 回调函数。当指定卡片设置隐私保护属性成功,error为undefined,否则为错误对象。 |
错误码:
错误码ID | 错误信息 |
---|---|
201 | Permissions denied. |
202 | The application is not a system application. |
401 | If the input parameter is not valid parameter. |
16500050 | An IPC connection error happened. |
16500060 | A service connection error happened, please try again later. |
16501000 | An internal functional error occurred. |
以上错误码的详细介绍请参见卡片错误码。
示例:
import formHost from '@ohos.app.form.formHost';
import Base from '@ohos.base';
let formIds: string[] = new Array('12400633174999288', '12400633174999289');
try {
formHost.notifyFormsPrivacyProtected(formIds, true, (error: Base.BusinessError) => {
if (error) {
console.error(`error, code: ${error.code}, message: ${error.message}`);
}
});
} catch(error) {
console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message}`);
}
notifyFormsPrivacyProtected
notifyFormsPrivacyProtected(formIds: Array<string>, isProtected: boolean): Promise<void>
通知指定卡片隐私保护状态改变。使用Promise异步回调。
需要权限:ohos.permission.REQUIRE_FORM
系统能力:SystemCapability.Ability.Form
参数:
参数名 | 类型 | 必填 | 说明 |
---|---|---|---|
formIds | Array<string> | 是 | 需要修改隐私保护的卡片标识列表。 |
isProtected | boolean | 是 | 是否进行隐私保护。 |
返回值:
类型 | 说明 |
---|---|
Promise<void> | 无返回结果的Promise对象。 |
错误码:
错误码ID | 错误信息 |
---|---|
201 | Permissions denied. |
202 | The application is not a system application. |
401 | If the input parameter is not valid parameter. |
16500050 | An IPC connection error happened. |
16500060 | A service connection error happened, please try again later. |
16501000 | An internal functional error occurred. |
以上错误码的详细介绍请参见卡片错误码。
import formHost from '@ohos.app.form.formHost';
import Base from '@ohos.base';
let formIds: string[] = new Array('12400633174999288', '12400633174999289');
try {
formHost.notifyFormsPrivacyProtected(formIds, true).then(() => {
console.log('formHost notifyFormsPrivacyProtected success');
}).catch((error: Base.BusinessError) => {
console.error(`error, code: ${error.code}, message: ${error.message}`);
});
} catch(error) {
console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message}`);
}
acquireFormData10+
acquireFormData(formId: string, callback: AsyncCallback<{[key: string]: Object}>): void
请求卡片提供方数据。使用callback异步回调。
模型约束: 此接口仅可在Stage模型下使用。
需要权限:ohos.permission.REQUIRE_FORM
系统能力:SystemCapability.Ability.Form
参数:
参数名 | 类型 | 必填 | 说明 |
---|---|---|---|
formId | string | 是 | 卡片标识。 |
callback | AsyncCallback<{[key: string]: Object} | 是 | 以callback方式返回接口运行结果及分享数据。 |
错误码:
错误码ID | 错误信息 |
---|---|
201 | Permissions denied. |
401 | If the input parameter is not valid parameter. |
16500050 | An IPC connection error happened. |
16500060 | A service connection error happened, please try again later. |
16500100 | Failed to obtain the configuration information. |
16501000 | An internal functional error occurred. |
以上错误码的详细介绍请参见卡片错误码。
示例:
import formHost from '@ohos.app.form.formHost';
import Base from '@ohos.base';
let formId: string = '12400633174999288';
try {
formHost.acquireFormData(formId, (error, data) => {
if (error) {
console.error(`error, code: ${error.code}, message: ${error.message}`);
} else {
console.log(`formHost acquireFormData, data: ${JSON.stringify(data)}`);
}
});
} catch(error) {
console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message}`);
}
acquireFormData10+
acquireFormData(formId: string): Promise<{[key: string]: Object}>
请求卡片提供方数据。使用Promise异步回调。
模型约束: 此接口仅可在Stage模型下使用。
需要权限:ohos.permission.REQUIRE_FORM
系统能力:SystemCapability.Ability.Form
参数:
参数名 | 类型 | 必填 | 说明 |
---|---|---|---|
formId | string | 是 | 卡片标识。 |
返回值:
类型 | 说明 |
---|---|
Promise<{[key: string]: Object}> | 以Promise方式返回接口运行结果及分享数据。 |
错误码:
错误码ID | 错误信息 |
---|---|
201 | Permissions denied. |
401 | If the input parameter is not valid parameter. |
16500050 | An IPC connection error happened. |
16500060 | A service connection error happened, please try again later. |
16500100 | Failed to obtain the configuration information. |
16501000 | An internal functional error occurred. |
以上错误码的详细介绍请参见卡片错误码。
import formHost from '@ohos.app.form.formHost';
import Base from '@ohos.base';
let formId: string = '12400633174999288';
try {
formHost.acquireFormData(formId).then((data) => {
console.log('formHost acquireFormData success' + data);
}).catch((error: Base.BusinessError) => {
console.error(`error, code: ${error.code}, message: ${error.message}`);
});
} catch(error) {
console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message}`);
}
最后
有很多小伙伴不知道学习哪些鸿蒙开发技术?不知道需要重点掌握哪些鸿蒙应用开发知识点?而且学习时频繁踩坑,最终浪费大量时间。所以有一份实用的鸿蒙(HarmonyOS NEXT)资料用来跟着学习是非常有必要的。
这份鸿蒙(HarmonyOS NEXT)资料包含了鸿蒙开发必掌握的核心知识要点,内容包含了(ArkTS、ArkUI开发组件、Stage模型、多端部署、分布式应用开发、音频、视频、WebGL、OpenHarmony多媒体技术、Napi组件、OpenHarmony内核、Harmony南向开发、鸿蒙项目实战等等)鸿蒙(HarmonyOS NEXT)技术知识点。
希望这一份鸿蒙学习资料能够给大家带来帮助,有需要的小伙伴自行领取,限时开源,先到先得~无套路领取!!
获取这份完整版高清学习路线,请点击→纯血版全套鸿蒙HarmonyOS学习资料
鸿蒙(HarmonyOS NEXT)最新学习路线
-
HarmonOS基础技能
- HarmonOS就业必备技能
- HarmonOS多媒体技术
- 鸿蒙NaPi组件进阶
- HarmonOS高级技能
- 初识HarmonOS内核
- 实战就业级设备开发
有了路线图,怎么能没有学习资料呢,小编也准备了一份联合鸿蒙官方发布笔记整理收纳的一套系统性的鸿蒙(OpenHarmony )学习手册(共计1236页)与鸿蒙(OpenHarmony )开发入门教学视频,内容包含:ArkTS、ArkUI、Web开发、应用模型、资源分类…等知识点。
获取以上完整版高清学习路线,请点击→纯血版全套鸿蒙HarmonyOS学习资料
《鸿蒙 (OpenHarmony)开发入门教学视频》
《鸿蒙生态应用开发V2.0白皮书》
《鸿蒙 (OpenHarmony)开发基础到实战手册》
OpenHarmony北向、南向开发环境搭建
《鸿蒙开发基础》
- ArkTS语言
- 安装DevEco Studio
- 运用你的第一个ArkTS应用
- ArkUI声明式UI开发
- .……
《鸿蒙开发进阶》
- Stage模型入门
- 网络管理
- 数据管理
- 电话服务
- 分布式应用开发
- 通知与窗口管理
- 多媒体技术
- 安全技能
- 任务管理
- WebGL
- 国际化开发
- 应用测试
- DFX面向未来设计
- 鸿蒙系统移植和裁剪定制
- ……
《鸿蒙进阶实战》
- ArkTS实践
- UIAbility应用
- 网络案例
- ……
获取以上完整鸿蒙HarmonyOS学习资料,请点击→纯血版全套鸿蒙HarmonyOS学习资料
总结
总的来说,华为鸿蒙不再兼容安卓,对中年程序员来说是一个挑战,也是一个机会。只有积极应对变化,不断学习和提升自己,他们才能在这个变革的时代中立于不败之地。