harmony 鸿蒙API Model Conversion List
API Model Conversion List
Certain APIs are available only in the FA model. To switch to the stage model, an adaptation is required. This topic lists these APIs and their substitutes in the stage model.
Context APIs
featureAbility APIs
particleAbility APIs
LifecycleForm APIs
APIs Available in FA Model Only | Substitute API File in Stage Model | Substitute API in Stage Model |
---|---|---|
onCreate?(want: Want): formBindingData.FormBindingData; | \@ohos.app.form.FormExtensionAbility.d.ts | onAddForm(want: Want): formBindingData.FormBindingData; |
onCastToNormal?(formId: string): void; | \@ohos.app.form.FormExtensionAbility.d.ts | onCastToNormalForm(formId: string): void; |
onUpdate?(formId: string): void; | \@ohos.app.form.FormExtensionAbility.d.ts | onUpdateForm(formId: string): void; |
onVisibilityChange?(newStatus: Record<string, number>): void; | \@ohos.app.form.FormExtensionAbility.d.ts | onChangeFormVisibility(newStatus: Record<string, number>): void; |
onEvent?(formId: string, message: string): void; | \@ohos.app.form.FormExtensionAbility.d.ts | onFormEvent(formId: string, message: string): void; |
onDestroy?(formId: string): void; | \@ohos.app.form.FormExtensionAbility.d.ts | onRemoveForm(formId: string): void; |
onAcquireFormState?(want: Want): formInfo.FormState; | \@ohos.app.form.FormExtensionAbility.d.ts | onAcquireFormState?(want: Want): formInfo.FormState; |
onShareForm?(formId: string): { [key: string]: any }; | \@ohos.app.form.FormExtensionAbility.d.ts | onShareForm?(formId: string): Record<string, Object>; |
LifecycleApp APIs
APIs Available in FA Model Only | Substitute API File in Stage Model | Substitute API in Stage Model |
---|---|---|
onShow?(): void; | \@ohos.window.d.ts | on(eventType: ‘windowStageEvent’, callback: Callback<WindowStageEventType>): void; Listens for the switching to the foreground. |
onHide?(): void; | \@ohos.window.d.ts | on(eventType: ‘windowStageEvent’, callback: Callback<WindowStageEventType>): void; Listens for the switching to the background. |
onDestroy?(): void; | \@ohos.app.ability.UIAbility.d.ts | onDestroy(): void; |
onCreate?(): void; | \@ohos.app.ability.UIAbility.d.ts | onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void; |
onWindowDisplayModeChanged?(isShownInMultiWindow: boolean, newConfig: resourceManager.Configuration): void; | There is no corresponding API in the stage model. | No corresponding API is provided. |
onStartContinuation?(): boolean; | There is no corresponding API in the stage model. | In the stage model, an application does not need to detect whether the continuation is successful (detected when the application initiates the continuation request). Therefore, the onStartContinuation() callback is deprecated. |
onSaveData?(data: Object): boolean; | \@ohos.app.ability.UIAbility.d.ts | onContinue(wantParam: Record<string, Object>): AbilityConstant.OnContinueResult; |
onCompleteContinuation?(result: number): void; | application\ContinueCallback.d.ts | onContinueDone(result: number): void; |
onRestoreData?(data: Object): void; | \@ohos.app.ability.UIAbility.d.ts | onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void; onNewWant(want: Want, launchParam: AbilityConstant.LaunchParam): void; In multiton or singleton mode, the target ability completes data restoration in the onCreate() callback. In the callback, launchParam.launchReason is used to determine whether it is a continuation-based launch scenario. If it is, the data saved before continuation can be obtained from the want parameter. |
onRemoteTerminated?(): void; | application\ContinueCallback.d.ts | onContinueDone(result: number): void; |
onSaveAbilityState?(outState: PacMap): void; | \@ohos.app.ability.UIAbility.d.ts | onSaveState(reason: AbilityConstant.StateType, wantParam : Record<string, Object>): AbilityConstant.OnSaveResult; |
onRestoreAbilityState?(inState: PacMap): void; | \@ohos.app.ability.UIAbility.d.ts | onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void; After an application is restarted, the onCreate() callback is triggered. In the callback, launchParam.launchReason is used to determine whether it is a self-recovery scenario. If it is, the data saved before the restart can be obtained from the want parameter. |
onInactive?(): void; | \@ohos.app.ability.UIAbility.d.ts | onBackground(): void; |
onActive?(): void; | \@ohos.app.ability.UIAbility.d.ts | onForeground(): void; |
onNewWant?(want: Want): void; | \@ohos.app.ability.UIAbility.d.ts | onNewWant(want: Want, launchParam: AbilityConstant.LaunchParam): void; |
onMemoryLevel?(level: number): void | \@ohos.app.ability.UIAbility.d.ts | onMemoryLevel(level: AbilityConstant.MemoryLevel): void; |
LifecycleService APIs
APIs Available in FA Model Only | Substitute API File in Stage Model | Substitute API in Stage Model |
---|---|---|
onStart?(): void; | \@ohos.app.ability.ServiceExtensionAbility.d.ts | onCreate(want: Want): void; |
onCommand?(want: Want, startId: number): void; | \@ohos.app.ability.ServiceExtensionAbility.d.ts | onRequest(want: Want, startId: number): void; |
onStop?(): void; | \@ohos.app.ability.ServiceExtensionAbility.d.ts | onDestroy(): void; |
onConnect?(want: Want): rpc.RemoteObject; | \@ohos.app.ability.ServiceExtensionAbility.d.ts | onConnect(want: Want): rpc.RemoteObject; |
onDisconnect?(want: Want): void; | \@ohos.app.ability.ServiceExtensionAbility.d.ts | onDisconnect(want: Want): void; |
onReconnect?(want: Want): void; | \@ohos.app.ability.ServiceExtensionAbility.d.ts | onReconnect(want: Want): void; |
LifecycleData APIs
APIs Available in FA Model Only | Substitute API File in Stage Model | Substitute API in Stage Model |
---|---|---|
update?(uri: string, valueBucket: rdb.ValuesBucket, predicates: dataAbility.DataAbilityPredicates, callback: AsyncCallback<number>): void; | \@ohos.application.DataShareExtensionAbility.d.ts | update?(uri: string, predicates: dataSharePredicates.DataSharePredicates, valueBucket: ValuesBucket, callback: AsyncCallback<number>): void; |
query?(uri: string, columns: Array<string>, predicates: dataAbility.DataAbilityPredicates, callback: AsyncCallback<ResultSet>): void; | \@ohos.application.DataShareExtensionAbility.d.ts | query?(uri: string, predicates: dataSharePredicates.DataSharePredicates, columns: Array<string>, callback: AsyncCallback<Object>): void; |
delete?(uri: string, predicates: dataAbility.DataAbilityPredicates, callback: AsyncCallback<number>): void; | \@ohos.application.DataShareExtensionAbility.d.ts | delete?(uri: string, predicates: dataSharePredicates.DataSharePredicates, callback: AsyncCallback<number>): void; |
normalizeUri?(uri: string, callback: AsyncCallback<string>): void; | \@ohos.application.DataShareExtensionAbility.d.ts | normalizeUri?(uri: string, callback: AsyncCallback<string>): void; |
batchInsert?(uri: string, valueBuckets: Array<rdb.ValuesBucket>, callback: AsyncCallback<number>): void; | \@ohos.application.DataShareExtensionAbility.d.ts | batchInsert?(uri: string, valueBuckets: Array<ValuesBucket>, callback: AsyncCallback<number>): void; |
denormalizeUri?(uri: string, callback: AsyncCallback<string>): void; | \@ohos.application.DataShareExtensionAbility.d.ts | denormalizeUri?(uri: string, callback: AsyncCallback<string>): void; |
insert?(uri: string, valueBucket: rdb.ValuesBucket, callback: AsyncCallback<number>): void; | \@ohos.application.DataShareExtensionAbility.d.ts | insert?(uri: string, valueBucket: ValuesBucket, callback: AsyncCallback<number>): void; |
openFile?(uri: string, mode: string, callback: AsyncCallback<number>): void; | There is no corresponding API in the stage model. | The stage model does not support cross-process URI access. You are advised to use the want parameter to carry the file descriptor and file information for cross-process file access. |
getFileTypes?(uri: string, mimeTypeFilter: string, callback: AsyncCallback<Array<string>>): void; | There is no corresponding API in the stage model. | The stage model does not support cross-process URI access. You are advised to use the want parameter to carry the file descriptor and file information for cross-process file access. |
onInitialized?(info: AbilityInfo): void; | \@ohos.application.DataShareExtensionAbility.d.ts | onCreate?(want: Want, callback: AsyncCallback<void>): void; |
getType?(uri: string, callback: AsyncCallback<string>): void; | There is no corresponding API in the stage model. | The stage model does not support cross-process URI access. You are advised to use the want parameter to carry the file descriptor and file information for cross-process file access. |
executeBatch?(ops: Array<DataAbilityOperation>, callback: AsyncCallback<Array<DataAbilityResult>>): void; | There is no corresponding API in the stage model. | No corresponding API is provided. |
call?(method: string, arg: string, extras: PacMap, callback: AsyncCallback<PacMap>): void; | There is no corresponding API in the stage model. | No corresponding API is provided. |
DataAbilityHelper APIs
mediaLibrary APIs
APIs Available in FA Model Only | Substitute API File in Stage Model | Substitute API in Stage Model |
---|---|---|
getMediaLibrary(): MediaLibrary; | \@ohos.file.photoAccessHelper.d.ts | getPhotoAccessHelper(context: Context): PhotoAccessHelper; |
Request APIs
resourceManager APIs
APIs Available in FA Model Only | Substitute API File in Stage Model | Substitute API in Stage Model |
---|---|---|
getResourceManager(callback: AsyncCallback<ResourceManager>): void; getResourceManager(bundleName: string, callback: AsyncCallback<ResourceManager>): void; getResourceManager(): Promise<ResourceManager>; getResourceManager(bundleName: string): Promise<ResourceManager>; |
application\Context.d.ts | resourceManager: resmgr.ResourceManager; |
Window APIs
APIs Available in FA Model Only | Substitute API File in Stage Model | Substitute API in Stage Model |
---|---|---|
create(id: string, type: WindowType, callback: AsyncCallback<Window>): void; create(id: string, type: WindowType): Promise<Window>; |
\@ohos.window.d.ts | createSubWindow(name: string, callback: AsyncCallback<Window>): void; createSubWindow(name: string): Promise; An application developed on the FA model uses window.create(id, WindowType.TYPE_APP) to create a subwindow, whereas an application developed on the stage model uses WindowStage.CreateSubWindow() to create a subwindow. |
getTopWindow(callback: AsyncCallback<Window>): void; getTopWindow(): Promise<Window>; |
\@ohos.window.d.ts | getLastWindow(ctx: BaseContext, callback: AsyncCallback<Window>): void; getLastWindow(ctx: BaseContext): Promise<Window>; |
TYPE_APP | The API is meaningless in the stage model. | An application developed on the FA model uses window.create(id, WindowType.TYPE_APP) to create a subwindow, whereas an application developed on the stage model uses WindowStage.CreateSubWindow() to create a subwindow. |
Storage APIs
APIs Available in FA Model Only | Substitute API File in Stage Model | Substitute API in Stage Model |
---|---|---|
GetStorageOptions | There is no corresponding API in the stage model. | The stage model uses Prefereces to replace Storage and has redesigned the input parameters. |
SetStorageOptions | There is no corresponding API in the stage model. | The stage model uses Prefereces to replace Storage and has redesigned the input parameters. |
ClearStorageOptions | There is no corresponding API in the stage model. | The stage model uses Prefereces to replace Storage and has redesigned the input parameters. |
DeleteStorageOptions | There is no corresponding API in the stage model. | The stage model uses Prefereces to replace Storage and has redesigned the input parameters. |
static get(options: GetStorageOptions): void; | \@ohos.data.preferences.d.ts | get(key: string, defValue: ValueType, callback: AsyncCallback<ValueType>): void; get(key: string, defValue: ValueType): Promise<ValueType>; |
static set(options: SetStorageOptions): void; | \@ohos.data.preferences.d.ts | put(key: string, value: ValueType, callback: AsyncCallback<void>): void; put(key: string, value: ValueType): Promise<void>; |
static clear(options?: ClearStorageOptions): void; | \@ohos.data.preferences.d.ts | clear(callback: AsyncCallback<void>): void; clear(): Promise<void>; |
static delete(options: DeleteStorageOptions): void; | \@ohos.data.preferences.d.ts | delete(key: string, callback: AsyncCallback<void>): void; delete(key: string): Promise<void>; |
key: string; | There is no corresponding API in the stage model. | The stage model uses Prefereces to replace Storage and has redesigned the input parameters. |
default?: string; | There is no corresponding API in the stage model. | The stage model uses Prefereces to replace Storage and has redesigned the input parameters. |
success?: (data: any) => void; | There is no corresponding API in the stage model. | The stage model uses Prefereces to replace Storage and has redesigned the input parameters. |
fail?: (data: string, code: number) => void; | There is no corresponding API in the stage model. | The stage model uses Prefereces to replace Storage and has redesigned the input parameters. |
complete?: () => void; | There is no corresponding API in the stage model. | The stage model uses Prefereces to replace Storage and has redesigned the input parameters. |
key: string; | There is no corresponding API in the stage model. | The stage model uses Prefereces to replace Storage and has redesigned the input parameters. |
value: string; | There is no corresponding API in the stage model. | The stage model uses Prefereces to replace Storage and has redesigned the input parameters. |
success?: () => void; | There is no corresponding API in the stage model. | The stage model uses Prefereces to replace Storage and has redesigned the input parameters. |
fail?: (data: string, code: number) => void; | There is no corresponding API in the stage model. | The stage model uses Prefereces to replace Storage and has redesigned the input parameters. |
complete?: () => void; | There is no corresponding API in the stage model. | The stage model uses Prefereces to replace Storage and has redesigned the input parameters. |
success?: () => void; | There is no corresponding API in the stage model. | The stage model uses Prefereces to replace Storage and has redesigned the input parameters. |
fail?: (data: string, code: number) => void; | There is no corresponding API in the stage model. | The stage model uses Prefereces to replace Storage and has redesigned the input parameters. |
complete?: () => void; | There is no corresponding API in the stage model. | The stage model uses Prefereces to replace Storage and has redesigned the input parameters. |
key: string; | There is no corresponding API in the stage model. | The stage model uses Prefereces to replace Storage and has redesigned the input parameters. |
success?: () => void; | There is no corresponding API in the stage model. | The stage model uses Prefereces to replace Storage and has redesigned the input parameters. |
fail?: (data: string, code: number) => void; | There is no corresponding API in the stage model. | The stage model uses Prefereces to replace Storage and has redesigned the input parameters. |
complete?: () => void; | There is no corresponding API in the stage model. | The stage model uses Prefereces to replace Storage and has redesigned the input parameters. |
ability APIs
APIs Available in FA Model Only | Substitute API File in Stage Model | Substitute API in Stage Model |
---|---|---|
export type DataAbilityOperation = _DataAbilityOperation; | There is no corresponding API in the stage model. | No corresponding API is provided. |
export type DataAbilityResult = _DataAbilityResult; | There is no corresponding API in the stage model. | No corresponding API is provided. |
export type AbilityResult = _AbilityResult; | \@ohos.app.ability.common.d.ts | export type AbilityResult = _AbilityResult; |
export type ConnectOptions = _ConnectOptions; | \@ohos.app.ability.common.d.ts | export type ConnectOptions = _ConnectOptions; |
export type StartAbilityParameter = _StartAbilityParameter; | There is no corresponding API in the stage model. | No corresponding API is provided. |
settings APIs
APIs Available in FA Model Only | Substitute API File in Stage Model | Substitute API in Stage Model |
---|---|---|
function getValue(dataAbilityHelper: DataAbilityHelper, name: string, callback: AsyncCallback | \@ohos.settings.d.ts | function getValue(context: Context, name: string, callback: AsyncCallback function getValue(context: Context, name: string): Promise |
function setValue(dataAbilityHelper: DataAbilityHelper, name: string, value: object, callback: AsyncCallback function setValue(dataAbilityHelper: DataAbilityHelper, name: string, value: object): Promise function setValue(context: Context, name: string, value: string, callback: AsyncCallback function setValue(context: Context, name: string, value: string): Promise function setValue(context: Context, name: string, value: string, domainName: string): Promise |
\@ohos.settings.d.ts | function setValue(context: Context, name: string, value: string, callback: AsyncCallback function setValue(context: Context, name: string, value: string): Promise |
function getValueSync(dataAbilityHelper: DataAbilityHelper, name: string, defValue: string): string; function getValueSync(context: Context, name: string, defValue: string): string; function getValueSync(context: Context, name: string, defValue: string, domainName: string): string; |
\@ohos.settings.d.ts | function getValueSync(context: Context, name: string, defValue: string): string; |
function setValueSync(dataAbilityHelper: DataAbilityHelper, name: string, value: string): boolean; function setValueSync(context: Context, name: string, value: string): boolean; function setValueSync(context: Context, name: string, value: string, domainName: string): boolean; |
\@ohos.settings.d.ts | function setValueSync(context: Context, name: string, value: string): boolean; |
dataAbilityOperation APIs
APIs Available in FA Model Only | Substitute API File in Stage Model | Substitute API in Stage Model |
---|---|---|
uri: string | The API is meaningless in the stage model. | Delete the API call. |
type: featureAbility.DataAbilityOperationType; | The API is meaningless in the stage model. | Delete the API call. |
valuesBucket?: rdb.ValuesBucket; | The API is meaningless in the stage model. | Delete the API call. |
valueBackReferences?: rdb.ValuesBucket; | The API is meaningless in the stage model. | Delete the API call. |
predicates?: dataAbility.DataAbilityPredicates; | The API is meaningless in the stage model. | Delete the API call. |
predicatesBackReferences?: Map |
The API is meaningless in the stage model. | Delete the API call. |
interrupted?: boolean; | The API is meaningless in the stage model. | Delete the API call. |
expectedCount?: number; | The API is meaningless in the stage model. | Delete the API call. |
dataAbilityResult APIs
APIs Available in FA Model Only | Substitute API File in Stage Model | Substitute API in Stage Model |
---|---|---|
uri?: string; | The API is meaningless in the stage model. | Delete the API call. |
count?: number; | The API is meaningless in the stage model. | Delete the API call. |
startAbilityParameter APIs
APIs Available in FA Model Only | Substitute API File in Stage Model | Substitute API in Stage Model |
---|---|---|
want: Want; | The API is meaningless in the stage model. | Delete the API call. |
abilityStartSetting?: { [key: string]: any }; | The API is meaningless in the stage model. | Delete the API call. |
abilityStartSettings?: Record |
The API is meaningless in the stage model. | Delete the API call. |
appVersionInfo APIs
APIs Available in FA Model Only | Substitute API File in Stage Model | Substitute API in Stage Model |
---|---|---|
export interface AppVersionInfo | ohos.bundle.bundleManager.d.ts | export interface BundleInfo |
readonly appName: string; | bundleManager\BundleInfo.d.ts | readonly name: string; |
readonly versionCode: number; | bundleManager\BundleInfo.d.ts | readonly versionCode: number; |
readonly versionName: string; | bundleManager\BundleInfo.d.ts | readonly versionName: string; |
bundleManager APIs
APIs Available in FA Model Only | Substitute API File in Stage Model | Substitute API in Stage Model |
---|---|---|
PAGE = 1 | The API is meaningless in the stage model. | Delete the API call. |
SERVICE = 2 | The API is meaningless in the stage model. | Delete the API call. |
DATA = 3 | The API is meaningless in the stage model. | Delete the API call. |
abilityInfo APIs
APIs Available in FA Model Only | Substitute API File in Stage Model | Substitute API in Stage Model |
---|---|---|
readonly targetAbility: string; | The API is meaningless in the stage model. | Delete the API call. |
readonly backgroundModes: number; | The API is meaningless in the stage model. | Delete the API call. |
readonly formEnabled: boolean; | The API is meaningless in the stage model. | Delete the API call. |
readonly type: bundle.AbilityType; | The API is meaningless in the stage model. | Delete the API call. |
readonly subType: bundle.AbilitySubType; | The API is meaningless in the stage model. | Delete the API call. |
readonly readPermission: string; | The API is meaningless in the stage model. | Delete the API call. |
readonly writePermission: string; | The API is meaningless in the stage model. | Delete the API call. |
readonly uri: string; | The API is meaningless in the stage model. | Delete the API call. |
readonly type: bundleManager.AbilityType; | The API is meaningless in the stage model. | Delete the API call. |
readonly readPermission: string; | The API is meaningless in the stage model. | Delete the API call. |
readonly writePermission: string; | The API is meaningless in the stage model. | Delete the API call. |
readonly uri: string; | The API is meaningless in the stage model. | Delete the API call. |
你可能感兴趣的鸿蒙文章
harmony 鸿蒙cl.arkui.1 Specification Change for RichEditor Menu Visibility When Scrolling After Popup
harmony 鸿蒙Bundle Manager Subsystem Changelog
0
赞
- 所属分类: 后端技术
- 本文标签:
热门推荐
-
2、 - 优质文章
-
3、 gate.io
-
7、 golang
-
9、 openharmony
-
10、 Vue中input框自动聚焦