Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
c6d74aec
D
Docs
项目概览
OpenHarmony
/
Docs
大约 2 年 前同步成功
通知
161
Star
293
Fork
28
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Docs
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
c6d74aec
编写于
3月 11, 2023
作者:
M
mingxihua
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
mingxihua@huawei.com.cn
Signed-off-by:
N
mingxihua
<
mingxihua@huawei.com
>
上级
0f29c7e7
变更
19
隐藏空白更改
内联
并排
Showing
19 changed file
with
223 addition
and
104 deletion
+223
-104
zh-cn/application-dev/reference/apis/js-apis-app-ability-abilityConstant.md
...dev/reference/apis/js-apis-app-ability-abilityConstant.md
+2
-2
zh-cn/application-dev/reference/apis/js-apis-app-ability-abilityLifecycleCallback.md
...ence/apis/js-apis-app-ability-abilityLifecycleCallback.md
+2
-2
zh-cn/application-dev/reference/apis/js-apis-app-ability-abilityManager.md
...-dev/reference/apis/js-apis-app-ability-abilityManager.md
+8
-6
zh-cn/application-dev/reference/apis/js-apis-app-ability-appManager.md
...tion-dev/reference/apis/js-apis-app-ability-appManager.md
+2
-2
zh-cn/application-dev/reference/apis/js-apis-app-ability-appRecovery.md
...ion-dev/reference/apis/js-apis-app-ability-appRecovery.md
+3
-3
zh-cn/application-dev/reference/apis/js-apis-app-ability-common.md
...lication-dev/reference/apis/js-apis-app-ability-common.md
+0
-2
zh-cn/application-dev/reference/apis/js-apis-app-ability-environmentCallback.md
...reference/apis/js-apis-app-ability-environmentCallback.md
+2
-2
zh-cn/application-dev/reference/apis/js-apis-app-ability-missionManager.md
...-dev/reference/apis/js-apis-app-ability-missionManager.md
+171
-50
zh-cn/application-dev/reference/apis/js-apis-app-ability-uiAbility.md
...ation-dev/reference/apis/js-apis-app-ability-uiAbility.md
+5
-12
zh-cn/application-dev/reference/apis/js-apis-app-form-formExtensionAbility.md
...v/reference/apis/js-apis-app-form-formExtensionAbility.md
+2
-0
zh-cn/application-dev/reference/apis/js-apis-app-form-formProvider.md
...ation-dev/reference/apis/js-apis-app-form-formProvider.md
+4
-2
zh-cn/application-dev/reference/apis/js-apis-application-configuration.md
...n-dev/reference/apis/js-apis-application-configuration.md
+5
-2
zh-cn/application-dev/reference/apis/js-apis-inner-ability-dataAbilityResult.md
...reference/apis/js-apis-inner-ability-dataAbilityResult.md
+0
-2
zh-cn/application-dev/reference/apis/js-apis-inner-ability-startAbilityParameter.md
...rence/apis/js-apis-inner-ability-startAbilityParameter.md
+1
-3
zh-cn/application-dev/reference/apis/js-apis-inner-application-abilityDelegator.md
...erence/apis/js-apis-inner-application-abilityDelegator.md
+1
-3
zh-cn/application-dev/reference/apis/js-apis-inner-application-applicationContext.md
...ence/apis/js-apis-inner-application-applicationContext.md
+5
-5
zh-cn/application-dev/reference/apis/js-apis-inner-application-errorObserver.md
...reference/apis/js-apis-inner-application-errorObserver.md
+2
-2
zh-cn/application-dev/reference/apis/js-apis-inner-application-eventHub.md
...-dev/reference/apis/js-apis-inner-application-eventHub.md
+4
-4
zh-cn/application-dev/reference/apis/js-apis-inner-application-missionListener.md
...ference/apis/js-apis-inner-application-missionListener.md
+4
-0
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-app-ability-abilityConstant.md
浏览文件 @
c6d74aec
...
...
@@ -99,7 +99,7 @@ import UIAbility from '@ohos.app.ability.UIAbility';
class
MyAbility
extends
UIAbility
{
onContinue
(
wantParam
)
{
return
AbilityConstant
.
OnConinueResult
.
AGREE
;
return
AbilityConstant
.
OnCon
t
inueResult
.
AGREE
;
}
}
```
...
...
@@ -132,7 +132,7 @@ let option = {
};
// 确保从上下文获取到context
this
.
context
.
startAbility
(
want
,
option
).
then
(()
=
{
this
.
context
.
startAbility
(
want
,
option
).
then
(()
=
>
{
console
.
log
(
'
Succeed to start ability.
'
);
}).
catch
((
error
)
=>
{
console
.
log
(
'
Failed to start ability with error:
'
+
JSON
.
stringify
(
error
));
...
...
zh-cn/application-dev/reference/apis/js-apis-app-ability-abilityLifecycleCallback.md
浏览文件 @
c6d74aec
...
...
@@ -275,7 +275,7 @@ export default class MyFirstAbility extends UIAbility {
// 2.通过applicationContext注册监听应用内生命周期
try
{
globalThis
.
lifecycleId
=
applicationContext
.
on
(
'
abilityLifecycle
'
,
abilityLifecycleCallback
);
console
.
log
(
'
registerAbilityLifecycleCallback
number:
'
+
JSON
.
stringify
(
lifecycleId
)
);
console
.
log
(
'
registerAbilityLifecycleCallback
lifecycleId: ${globalThis.lifecycleId}
'
);
}
catch
(
paramError
)
{
console
.
log
(
'
error:
'
+
paramError
.
code
+
'
,
'
+
paramError
.
message
);
}
...
...
@@ -285,7 +285,7 @@ export default class MyFirstAbility extends UIAbility {
MySecondAbility.ts
```
ts
import
UIAbility
from
'
ohos.app.ability.UIAbility
'
;
import
UIAbility
from
'
@
ohos.app.ability.UIAbility
'
;
export
default
class
MySecondAbility
extends
UIAbility
{
onDestroy
()
{
...
...
zh-cn/application-dev/reference/apis/js-apis-app-ability-abilityManager.md
浏览文件 @
c6d74aec
...
...
@@ -59,12 +59,13 @@ updateConfiguration(config: Configuration, callback: AsyncCallback\<void>): void
```
ts
import
abilityManager
from
'
@ohos.app.ability.abilityManager
'
;
import
ConfigurationConstant
from
'
@ohos.app.ability.ConfigurationConstant
'
;
const
config
=
{
language
:
'
Zh-Hans
'
,
// 简体中文
colorMode
:
COLOR_MODE_LIGHT
,
// 浅色模式
direction
:
DIRECTION_VERTICAL
,
// 垂直方向
screenDensity
:
SCREEN_DENSITY_SDPI
,
// 屏幕像素密度为'sdpi'
colorMode
:
C
onfigurationConstant
.
ColorMode
.
C
OLOR_MODE_LIGHT
,
// 浅色模式
direction
:
ConfigurationConstant
.
Direction
.
DIRECTION_VERTICAL
,
// 垂直方向
screenDensity
:
ConfigurationConstant
.
ScreenDensity
.
SCREEN_DENSITY_SDPI
,
// 屏幕像素密度为'sdpi'
displayId
:
1
,
// 应用在Id为1的物理屏上显示
hasPointerDevice
:
true
,
// 指针类型设备已连接
};
...
...
@@ -117,12 +118,13 @@ updateConfiguration(config: Configuration): Promise\<void>
```
ts
import
abilityManager
from
'
@ohos.app.ability.abilityManager
'
;
import
ConfigurationConstant
from
'
@ohos.app.ability.ConfigurationConstant
'
;
const
config
=
{
language
:
'
Zh-Hans
'
,
// 简体中文
colorMode
:
COLOR_MODE_LIGHT
,
// 浅色模式
direction
:
DIRECTION_VERTICAL
,
// 垂直方向
screenDensity
:
SCREEN_DENSITY_SDPI
,
// 屏幕像素密度为'sdpi'
colorMode
:
C
onfigurationConstant
.
ColorMode
.
C
OLOR_MODE_LIGHT
,
// 浅色模式
direction
:
ConfigurationConstant
.
Direction
.
DIRECTION_VERTICAL
,
// 垂直方向
screenDensity
:
ConfigurationConstant
.
ScreenDensity
.
SCREEN_DENSITY_SDPI
,
// 屏幕像素密度为'sdpi'
displayId
:
1
,
// 应用在Id为1的物理屏上显示
hasPointerDevice
:
true
,
// 指针类型设备已连接
};
...
...
zh-cn/application-dev/reference/apis/js-apis-app-ability-appManager.md
浏览文件 @
c6d74aec
...
...
@@ -459,7 +459,7 @@ off(type: 'applicationState', observerId: number, callback: AsyncCallback\<void
```
ts
import
appManager
from
'
@ohos.app.ability.appManager
'
;
let
observeId
=
0
;
let
observe
r
Id
=
0
;
// 1.注册应用状态监听器
let
applicationStateObserver
=
{
...
...
@@ -540,7 +540,7 @@ off(type: 'applicationState', observerId: number): Promise\<void>;
```
ts
import
appManager
from
'
@ohos.app.ability.appManager
'
;
let
observeId
=
0
;
let
observe
r
Id
=
0
;
// 1.注册应用状态监听器
let
applicationStateObserver
=
{
...
...
zh-cn/application-dev/reference/apis/js-apis-app-ability-appRecovery.md
浏览文件 @
c6d74aec
...
...
@@ -72,9 +72,9 @@ import AbilityStage from '@ohos.app.ability.AbilityStage';
export
default
class
MyAbilityStage
extends
AbilityStage
{
onCreate
()
{
appRecovery
.
enableAppRecovery
(
appRecovery
.
RestartFlag
::
ALWAYS_RESTART
,
appRecovery
.
SaveOccasionFlag
::
SAVE_WHEN_ERROR
,
appRecovery
.
SaveModeFlag
::
SAVE_WITH_FILE
appRecovery
.
RestartFlag
.
ALWAYS_RESTART
,
appRecovery
.
SaveOccasionFlag
.
SAVE_WHEN_ERROR
,
appRecovery
.
SaveModeFlag
.
SAVE_WITH_FILE
);
}
}
...
...
zh-cn/application-dev/reference/apis/js-apis-app-ability-common.md
浏览文件 @
c6d74aec
...
...
@@ -24,7 +24,6 @@ import common from '@ohos.app.ability.common';
| Context |
[
Context
](
js-apis-inner-application-context.md
)
| 否 | Context二级模块。 |
| ExtensionContext |
[
ExtensionContext
](
js-apis-inner-application-extensionContext.md
)
| 否 | ExtensionContext二级模块。 |
| FormExtensionContext |
[
FormExtensionContext
](
js-apis-inner-application-formExtensionContext.md
)
| 否 | FormExtensionContext二级模块。 |
| AreaMode |
[
AreaMode
](
#areamode
)
| 否 | AreaMode枚举值。 |
| EventHub |
[
EventHub
](
js-apis-inner-application-eventHub.md
)
| 否 | EventHub二级模块。 |
| PermissionRequestResult |
[
PermissionRequestResult
](
js-apis-inner-application-permissionRequestResult.md
)
| 否 | PermissionRequestResult二级模块。 |
| PacMap |
[
PacMap
](
js-apis-inner-ability-dataAbilityHelper.md#PacMap
)
| 否 | PacMap二级模块。 |
...
...
@@ -42,7 +41,6 @@ let baseContext: common.BaseContext;
let
context
:
common
.
Context
;
let
extensionContext
:
common
.
ExtensionContext
;
let
formExtensionContext
:
common
.
FormExtensionContext
;
let
areaMode
:
common
.
AreaMode
;
let
eventHub
:
common
.
EventHub
;
let
permissionRequestResult
:
common
.
PermissionRequestResult
;
let
pacMap
:
common
.
PacMap
;
...
...
zh-cn/application-dev/reference/apis/js-apis-app-ability-environmentCallback.md
浏览文件 @
c6d74aec
...
...
@@ -47,11 +47,11 @@ onMemoryLevel(level: AbilityConstant.MemoryLevel): void;
```
ts
import
Ability
from
'
@ohos.application.
Ability
'
;
import
UIAbility
from
'
@ohos.app.ability.UI
Ability
'
;
let
callbackId
;
export
default
class
MyAbility
extends
Ability
{
export
default
class
MyAbility
extends
UI
Ability
{
onCreate
()
{
console
.
log
(
'
MyAbility onCreate
'
);
globalThis
.
applicationContext
=
this
.
context
.
getApplicationContext
();
...
...
zh-cn/application-dev/reference/apis/js-apis-app-ability-missionManager.md
浏览文件 @
c6d74aec
...
...
@@ -43,20 +43,63 @@ on(type:'mission', listener: MissionListener): number;
**示例:**
```
ts
let
listener
=
{
onMissionCreated
:
function
(
mission
)
{
console
.
log
(
'
--------onMissionCreated-------
'
);},
onMissionDestroyed
:
function
(
mission
)
{
console
.
log
(
'
--------onMissionDestroyed-------
'
);},
onMissionSnapshotChanged
:
function
(
mission
)
{
console
.
log
(
'
--------onMissionSnapshotChanged-------
'
);},
onMissionMovedToFront
:
function
(
mission
)
{
console
.
log
(
'
--------onMissionMovedToFront-------
'
);},
onMissionIconUpdated
:
function
(
mission
,
icon
)
{
console
.
log
(
'
--------onMissionIconUpdated-------
'
);},
onMissionClosed
:
function
(
mission
)
{
console
.
log
(
'
--------onMissionClosed-------
'
);}
};
console
.
log
(
'
registerMissionListener
'
);
try
{
let
listenerid
=
missionManager
.
on
(
'
mission
'
,
listener
);
}
catch
(
paramError
)
{
console
.
log
(
'
error:
'
+
paramError
.
code
+
'
,
'
+
paramError
.
message
);
}
import
missionManager
from
'
@ohos.app.ability.missionManager
'
;
import
UIAbility
from
'
@ohos.app.ability.UIAbility
'
;
let
listener
=
{
onMissionCreated
:
function
(
mission
)
{
console
.
log
(
'
--------onMissionCreated-------
'
);},
onMissionDestroyed
:
function
(
mission
)
{
console
.
log
(
'
--------onMissionDestroyed-------
'
);},
onMissionSnapshotChanged
:
function
(
mission
)
{
console
.
log
(
'
--------onMissionSnapshotChanged-------
'
);},
onMissionMovedToFront
:
function
(
mission
)
{
console
.
log
(
'
--------onMissionMovedToFront-------
'
);},
onMissionIconUpdated
:
function
(
mission
,
icon
)
{
console
.
log
(
'
--------onMissionIconUpdated-------
'
);},
onMissionClosed
:
function
(
mission
)
{
console
.
log
(
'
--------onMissionClosed-------
'
);},
onMissionLabelUpdated
:
function
(
mission
)
{
console
.
log
(
'
--------onMissionLabelUpdated-------
'
);}
};
let
listenerId
=
-
1
;
export
default
class
EntryAbility
extends
UIAbility
{
onCreate
(
want
,
launchParam
)
{
console
.
log
(
'
[Demo] EntryAbility onCreate
'
);
globalThis
.
abilityWant
=
want
;
globalThis
.
context
=
this
.
context
;
}
onDestroy
()
{
try
{
if
(
listenerId
!==
-
1
)
{
missionManager
.
off
(
'
mission
'
,
listenerId
).
catch
(
function
(
err
)
{
console
.
log
(
err
);
});
}
}
catch
(
paramError
)
{
console
.
error
(
'
error: ${paramError.code}, ${paramError.message}
'
);
}
console
.
log
(
'
[Demo] EntryAbility onDestroy
'
);
}
onWindowStageCreate
(
windowStage
)
{
// Main window is created, set main page for this ability
console
.
log
(
'
[Demo] EntryAbility onWindowStageCreate
'
);
try
{
listenerId
=
missionManager
.
on
(
'
mission
'
,
listener
);
}
catch
(
paramError
)
{
console
.
error
(
'
error: ${paramError.code}, ${paramError.message}
'
);
}
windowStage
.
loadContent
(
'
pages/index
'
,
(
err
,
data
)
=>
{
if
(
err
.
code
)
{
console
.
error
(
'
Failed to load the content. Cause: ${JSON.stringify(err)}
'
);
return
;
}
console
.
info
(
'
Succeeded in loading the content. Data: ${JSON.stringify(data)}
'
);
});
if
(
globalThis
.
flag
)
{
return
;
}
}
};
```
...
...
@@ -82,24 +125,63 @@ off(type: 'mission', listenerId: number, callback: AsyncCallback<void>): v
**示例:**
```
ts
let
listener
=
{
onMissionCreated
:
function
(
mission
)
{
console
.
log
(
'
--------onMissionCreated-------
'
);},
onMissionDestroyed
:
function
(
mission
)
{
console
.
log
(
'
--------onMissionDestroyed-------
'
);},
onMissionSnapshotChanged
:
function
(
mission
)
{
console
.
log
(
'
--------onMissionSnapshotChanged-------
'
);},
onMissionMovedToFront
:
function
(
mission
)
{
console
.
log
(
'
--------onMissionMovedToFront-------
'
);},
onMissionIconUpdated
:
function
(
mission
,
icon
)
{
console
.
log
(
'
--------onMissionIconUpdated-------
'
);},
onMissionClosed
:
function
(
mission
)
{
console
.
log
(
'
--------onMissionClosed-------
'
);}
};
console
.
log
(
'
registerMissionListener
'
);
try
{
let
listenerid
=
missionManager
.
registerMissionListener
(
listener
);
missionManager
.
unregisterMissionListener
(
listenerid
,
(
error
)
=>
{
console
.
log
(
'
unregisterMissionListener
'
);
});
}
catch
(
paramError
)
{
console
.
log
(
'
error:
'
+
paramError
.
code
+
'
,
'
+
paramError
.
message
);
}
import
missionManager
from
'
@ohos.app.ability.missionManager
'
;
import
UIAbility
from
'
@ohos.app.ability.UIAbility
'
;
let
listener
=
{
onMissionCreated
:
function
(
mission
)
{
console
.
log
(
'
--------onMissionCreated-------
'
);},
onMissionDestroyed
:
function
(
mission
)
{
console
.
log
(
'
--------onMissionDestroyed-------
'
);},
onMissionSnapshotChanged
:
function
(
mission
)
{
console
.
log
(
'
--------onMissionSnapshotChanged-------
'
);},
onMissionMovedToFront
:
function
(
mission
)
{
console
.
log
(
'
--------onMissionMovedToFront-------
'
);},
onMissionIconUpdated
:
function
(
mission
,
icon
)
{
console
.
log
(
'
--------onMissionIconUpdated-------
'
);},
onMissionClosed
:
function
(
mission
)
{
console
.
log
(
'
--------onMissionClosed-------
'
);},
onMissionLabelUpdated
:
function
(
mission
)
{
console
.
log
(
'
--------onMissionLabelUpdated-------
'
);}
};
let
listenerId
=
-
1
;
export
default
class
EntryAbility
extends
UIAbility
{
onCreate
(
want
,
launchParam
)
{
console
.
log
(
'
[Demo] EntryAbility onCreate
'
);
globalThis
.
abilityWant
=
want
;
globalThis
.
context
=
this
.
context
;
}
onDestroy
()
{
try
{
if
(
listenerId
!==
-
1
)
{
missionManager
.
off
(
'
mission
'
,
listenerId
,
(
err
)
=>
{
console
.
log
(
err
);
});
}
}
catch
(
paramError
)
{
console
.
error
(
'
error: ${paramError.code}, ${paramError.message}
'
);
}
console
.
log
(
'
[Demo] EntryAbility onDestroy
'
);
}
onWindowStageCreate
(
windowStage
)
{
// Main window is created, set main page for this ability
console
.
log
(
'
[Demo] EntryAbility onWindowStageCreate
'
);
try
{
listenerId
=
missionManager
.
on
(
'
mission
'
,
listener
);
}
catch
(
paramError
)
{
console
.
error
(
'
error: ${paramError.code}, ${paramError.message}
'
);
}
windowStage
.
loadContent
(
'
pages/index
'
,
(
err
,
data
)
=>
{
if
(
err
.
code
)
{
console
.
error
(
'
Failed to load the content. Cause: ${JSON.stringify(err)}
'
);
return
;
}
console
.
info
(
'
Succeeded in loading the content. Data: ${JSON.stringify(data)}
'
);
});
if
(
globalThis
.
flag
)
{
return
;
}
}
};
```
...
...
@@ -130,24 +212,63 @@ off(type: 'mission', listenerId: number): Promise<void>;
**示例:**
```
ts
let
listener
=
{
onMissionCreated
:
function
(
mission
)
{
console
.
log
(
'
--------onMissionCreated-------
'
);},
onMissionDestroyed
:
function
(
mission
)
{
console
.
log
(
'
--------onMissionDestroyed-------
'
);},
onMissionSnapshotChanged
:
function
(
mission
)
{
console
.
log
(
'
--------onMissionSnapshotChanged-------
'
);},
onMissionMovedToFront
:
function
(
mission
)
{
console
.
log
(
'
--------onMissionMovedToFront-------
'
);},
onMissionIconUpdated
:
function
(
mission
,
icon
)
{
console
.
log
(
'
--------onMissionIconUpdated-------
'
);},
onMissionClosed
:
function
(
mission
)
{
console
.
log
(
'
--------onMissionClosed-------
'
);}
};
console
.
log
(
'
registerMissionListener
'
);
try
{
let
listenerid
=
missionManager
.
registerMissionListener
(
listener
);
missionManager
.
unregisterMissionListener
(
listenerid
).
catch
(
function
(
err
)
{
console
.
log
(
err
);
});
}
catch
(
paramError
)
{
console
.
log
(
'
error:
'
+
paramError
.
code
+
'
,
'
+
paramError
.
message
);
}
import
missionManager
from
'
@ohos.app.ability.missionManager
'
;
import
UIAbility
from
'
@ohos.app.ability.UIAbility
'
;
let
listener
=
{
onMissionCreated
:
function
(
mission
)
{
console
.
log
(
'
--------onMissionCreated-------
'
);},
onMissionDestroyed
:
function
(
mission
)
{
console
.
log
(
'
--------onMissionDestroyed-------
'
);},
onMissionSnapshotChanged
:
function
(
mission
)
{
console
.
log
(
'
--------onMissionSnapshotChanged-------
'
);},
onMissionMovedToFront
:
function
(
mission
)
{
console
.
log
(
'
--------onMissionMovedToFront-------
'
);},
onMissionIconUpdated
:
function
(
mission
,
icon
)
{
console
.
log
(
'
--------onMissionIconUpdated-------
'
);},
onMissionClosed
:
function
(
mission
)
{
console
.
log
(
'
--------onMissionClosed-------
'
);},
onMissionLabelUpdated
:
function
(
mission
)
{
console
.
log
(
'
--------onMissionLabelUpdated-------
'
);}
};
let
listenerId
=
-
1
;
export
default
class
EntryAbility
extends
UIAbility
{
onCreate
(
want
,
launchParam
)
{
console
.
log
(
'
[Demo] EntryAbility onCreate
'
);
globalThis
.
abilityWant
=
want
;
globalThis
.
context
=
this
.
context
;
}
onDestroy
()
{
try
{
if
(
listenerId
!==
-
1
)
{
missionManager
.
off
(
'
mission
'
,
listenerId
).
catch
(
function
(
err
)
{
console
.
log
(
err
);
});
}
}
catch
(
paramError
)
{
console
.
error
(
'
error: ${paramError.code}, ${paramError.message}
'
);
}
console
.
log
(
'
[Demo] EntryAbility onDestroy
'
);
}
onWindowStageCreate
(
windowStage
)
{
// Main window is created, set main page for this ability
console
.
log
(
'
[Demo] EntryAbility onWindowStageCreate
'
);
try
{
listenerId
=
missionManager
.
on
(
'
mission
'
,
listener
);
}
catch
(
paramError
)
{
console
.
error
(
'
error: ${paramError.code}, ${paramError.message}
'
);
}
windowStage
.
loadContent
(
'
pages/index
'
,
(
err
,
data
)
=>
{
if
(
err
.
code
)
{
console
.
error
(
'
Failed to load the content. Cause: ${JSON.stringify(err)}
'
);
return
;
}
console
.
info
(
'
Succeeded in loading the content. Data: ${JSON.stringify(data)}
'
);
});
if
(
globalThis
.
flag
)
{
return
;
}
}
};
```
...
...
zh-cn/application-dev/reference/apis/js-apis-app-ability-uiAbility.md
浏览文件 @
c6d74aec
...
...
@@ -205,7 +205,7 @@ onContinue(wantParam: { [key: string]: Object }): AbilityConstant.OnContinueResu
```
ts
import
AbilityConstant
from
'
@ohos.app.ability.AbilityConstant
'
;
class
MyUIAbility
extends
UI
Ability
{
class
MyUIAbility
extends
Ability
{
onContinue
(
wantParams
)
{
console
.
log
(
'
onContinue
'
);
wantParams
[
'
myData
'
]
=
'
my1234567
'
;
...
...
@@ -233,7 +233,7 @@ onNewWant(want: Want, launchParams: AbilityConstant.LaunchParam): void;
**示例:**
```
ts
class
MyUIAbility
extends
UI
Ability
{
class
MyUIAbility
extends
Ability
{
onNewWant
(
want
,
launchParams
)
{
console
.
log
(
'
onNewWant, want:
'
+
want
.
abilityName
);
console
.
log
(
'
onNewWant, launchParams:
'
+
JSON
.
stringify
(
launchParams
));
...
...
@@ -293,7 +293,7 @@ onSaveState(reason: AbilityConstant.StateType, wantParam : {[key: string]: Objec
```
ts
import
AbilityConstant
from
'
@ohos.app.ability.AbilityConstant
'
;
class
MyUIAbility
extends
UI
Ability
{
class
MyUIAbility
extends
Ability
{
onSaveState
(
reason
,
wantParam
)
{
console
.
log
(
'
onSaveState
'
);
wantParam
[
'
myData
'
]
=
'
my1234567
'
;
...
...
@@ -339,7 +339,6 @@ call(method: string, data: rpc.Parcelable): Promise<void>;
**示例:**
```
ts
import
Ability
from
'
@ohos.app.ability.UIAbility
'
;
class
MyMessageAble
{
// 自定义的Sequenceable数据结构
name
:
''
str
:
''
...
...
@@ -420,7 +419,6 @@ callWithResult(method: string, data: rpc.Parcelable): Promise<rpc.MessageParc
**示例:**
```
ts
import
Ability
from
'
@ohos.app.ability.UIAbility
'
;
class
MyMessageAble
{
name
:
''
str
:
''
...
...
@@ -492,7 +490,6 @@ release(): void;
**示例:**
```
ts
import
Ability
from
'
@ohos.app.ability.UIAbility
'
;
let
caller
;
export
default
class
MainAbility
extends
Ability
{
onWindowStageCreate
(
windowStage
)
{
...
...
@@ -533,7 +530,6 @@ release(): void;
**示例:**
```
ts
import
Ability
from
'
@ohos.application.Ability
'
;
let
caller
;
export
default
class
MainAbility
extends
Ability
{
onWindowStageCreate
(
windowStage
)
{
...
...
@@ -584,7 +580,6 @@ release(): void;
**示例:**
```
ts
import
Ability
from
'
@ohos.app.ability.UIAbility
'
;
let
caller
;
export
default
class
MainAbility
extends
Ability
{
onWindowStageCreate
(
windowStage
)
{
...
...
@@ -636,7 +631,7 @@ off(type: 'release', callback: OnReleaseCallback): void;
```
ts
let
caller
;
export
default
class
MainUIAbility
extends
UI
Ability
{
export
default
class
MainUIAbility
extends
Ability
{
onWindowStageCreate
(
windowStage
)
{
this
.
context
.
startAbilityByCall
({
bundleName
:
'
com.example.myservice
'
,
...
...
@@ -687,7 +682,7 @@ off(type: 'release'): void;
```
ts
let
caller
;
export
default
class
MainUIAbility
extends
UI
Ability
{
export
default
class
MainUIAbility
extends
Ability
{
onWindowStageCreate
(
windowStage
)
{
this
.
context
.
startAbilityByCall
({
bundleName
:
'
com.example.myservice
'
,
...
...
@@ -742,7 +737,6 @@ on(method: string, callback: CalleeCallback): void;
**示例:**
```
ts
import
Ability
from
'
@ohos.app.ability.UIAbility
'
;
class
MyMessageAble
{
name
:
''
str
:
''
...
...
@@ -809,7 +803,6 @@ off(method: string): void;
**示例:**
```
ts
import
Ability
from
'
@ohos.app.ability.UIAbility
'
;
let
method
=
'
call_Function
'
;
export
default
class
MainAbility
extends
Ability
{
onCreate
(
want
,
launchParam
)
{
...
...
zh-cn/application-dev/reference/apis/js-apis-app-form-formExtensionAbility.md
浏览文件 @
c6d74aec
...
...
@@ -45,6 +45,8 @@ onAddForm(want: Want): formBindingData.FormBindingData
```
ts
import
FormExtensionAbility
from
'
@ohos.app.form.FormExtensionAbility
'
;
import
formBindingData
from
'
@ohos.app.form.formBindingData
'
;
export
default
class
MyFormExtensionAbility
extends
FormExtensionAbility
{
onAddForm
(
want
)
{
console
.
log
(
'
FormExtensionAbility onAddForm, want:
'
+
want
.
abilityName
);
...
...
zh-cn/application-dev/reference/apis/js-apis-app-form-formProvider.md
浏览文件 @
c6d74aec
...
...
@@ -243,7 +243,8 @@ getFormsInfo(filter: formInfo.FormInfoFilter, callback: AsyncCallback<Array&l
**示例:**
```
ts
import
formInfo
from
'
@ohos.application.formInfo
'
;
import
formInfo
from
'
@ohos.app.form.formInfo
'
;
const
filter
:
formInfo
.
FormInfoFilter
=
{
// get info of forms belong to module entry.
moduleName
:
'
entry
'
...
...
@@ -291,7 +292,8 @@ getFormsInfo(filter?: formInfo.FormInfoFilter): Promise<Array<formInfo.For
**示例:**
```
ts
import
formInfo
from
'
@ohos.application.formInfo
'
;
import
formInfo
from
'
@ohos.app.form.formInfo
'
;
const
filter
:
formInfo
.
FormInfoFilter
=
{
// get info of forms belong to module entry.
moduleName
:
'
entry
'
...
...
zh-cn/application-dev/reference/apis/js-apis-application-configuration.md
浏览文件 @
c6d74aec
...
...
@@ -18,7 +18,7 @@
**示例:**
```
ts
import
Ability
from
'
@ohos.app
lication.Ability
'
import
Ability
from
'
@ohos.app
.ability.UIAbility
'
;
import
Window
from
'
@ohos.window
'
export
default
class
MainAbility
extends
Ability
{
...
...
@@ -34,11 +34,14 @@ export default class MainAbility extends Ability {
console
.
info
(
`envCallback onConfigurationUpdated success:
${
JSON
.
stringify
(
config
)}
`
);
let
language
=
config
.
language
;
let
colorMode
=
config
.
colorMode
;
},
onMemoryLevel
(
level
){
console
.
log
(
'
onMemoryLevel level: ${JSON.stringify(level)}
'
);
}
};
let
applicationContext
=
this
.
context
.
getApplicationContext
();
applicationContext
.
registerEnvironmentCallback
(
envCallback
);
applicationContext
.
on
(
'
environment
'
,
envCallback
);
windowStage
.
loadContent
(
'
pages/index
'
,
(
err
,
data
)
=>
{
if
(
err
.
code
)
{
...
...
zh-cn/application-dev/reference/apis/js-apis-inner-ability-dataAbilityResult.md
浏览文件 @
c6d74aec
...
...
@@ -25,11 +25,9 @@ try {
DAHelper
=
featureAbility
.
acquireDataAbilityHelper
(
dataAbilityUri
);
if
(
DAHelper
==
null
)
{
console
.
error
(
'
DAHelper is null
'
);
return
;
}
}
catch
(
err
)
{
console
.
error
(
'
acquireDataAbilityHelper fail, error:
'
+
JSON
.
stringify
(
err
));
return
;
}
let
valueBucket
=
{
...
...
zh-cn/application-dev/reference/apis/js-apis-inner-ability-startAbilityParameter.md
浏览文件 @
c6d74aec
...
...
@@ -38,7 +38,5 @@ let startAbilityParameter = {
featureAbility
.
startAbility
(
startAbilityParameter
,
(
err
,
data
)
=>
{
console
.
log
(
'
errCode :
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
data :
'
+
JSON
.
stringify
(
data
));
}
catch
(
error
)
{
console
.
log
(
'
startAbility error:
'
+
JSON
.
stringify
(
error
));
}
});
```
\ No newline at end of file
zh-cn/application-dev/reference/apis/js-apis-inner-application-abilityDelegator.md
浏览文件 @
c6d74aec
...
...
@@ -10,9 +10,7 @@ AbilityDelegator提供添加用于监视指定ability的生命周期状态更改
通过AbilityDelegatorRegistry中
[
getAbilityDelegator
](
js-apis-app-ability-abilityDelegatorRegistry.md#abilitydelegatorregistrygetabilitydelegator
)
方法获取。
```
ts
import
AbilityDelegatorRegistry
from
'
@ohos.application.abilityDelegatorRegistry
'
let
abilityDelegator
=
AbilityDelegatorRegistry
.
getAbilityDelegator
();
import
AbilityDelegatorRegistry
from
'
@ohos.application.abilityDelegatorRegistry
'
;
```
## AbilityDelegator
...
...
zh-cn/application-dev/reference/apis/js-apis-inner-application-applicationContext.md
浏览文件 @
c6d74aec
...
...
@@ -115,7 +115,7 @@ export default class EntryAbility extends UIAbility {
onDestroy
()
{
let
applicationContext
=
this
.
context
.
getApplicationContext
();
console
.
log
(
'
stage applicationContext:
'
+
applicationContext
);
applicationContext
.
off
(
type
:
'
abilityLifecycle
'
,
lifecycleId
,
(
error
,
data
)
=>
{
applicationContext
.
off
(
'
abilityLifecycle
'
,
lifecycleId
,
(
error
,
data
)
=>
{
console
.
log
(
'
unregisterAbilityLifecycleCallback success, err:
'
+
JSON
.
stringify
(
error
));
});
}
...
...
@@ -148,7 +148,7 @@ export default class MyAbility extends Ability {
onDestroy
()
{
let
applicationContext
=
this
.
context
.
getApplicationContext
();
console
.
log
(
'
stage applicationContext:
'
+
applicationContext
);
applicationContext
.
off
(
type
:
'
abilityLifecycle
'
,
lifecycleId
);
applicationContext
.
off
(
'
abilityLifecycle
'
,
lifecycleId
);
}
}
```
...
...
@@ -185,7 +185,7 @@ export default class EntryAbility extends UIAbility {
onCreate
()
{
console
.
log
(
'
MyAbility onCreate
'
)
globalThis
.
applicationContext
=
this
.
context
.
getApplicationContext
();
let
E
nvironmentCallback
=
{
let
e
nvironmentCallback
=
{
onConfigurationUpdated
(
config
){
console
.
log
(
'
onConfigurationUpdated config:
'
+
JSON
.
stringify
(
config
));
},
...
...
@@ -196,8 +196,8 @@ export default class EntryAbility extends UIAbility {
// 1.获取applicationContext
let
applicationContext
=
globalThis
.
applicationContext
;
// 2.通过applicationContext注册监听应用内生命周期
callbackId
=
applicationContext
.
on
(
'
environment
'
,
E
nvironmentCallback
);
console
.
log
(
'
registerEnvironmentCallback
number:
'
+
JSON
.
stringify
(
callbackId
)
);
callbackId
=
applicationContext
.
on
(
'
environment
'
,
e
nvironmentCallback
);
console
.
log
(
'
registerEnvironmentCallback
callbackId: ${callbackId}
'
);
}
}
```
...
...
zh-cn/application-dev/reference/apis/js-apis-inner-application-errorObserver.md
浏览文件 @
c6d74aec
...
...
@@ -19,12 +19,12 @@ onUnhandledException(errMsg: string): void;
**示例:**
```
ts
import
errorManager
from
'
@ohos.app
lication
.errorManager
'
;
import
errorManager
from
'
@ohos.app
.ability
.errorManager
'
;
let
observer
=
{
onUnhandledException
(
errorMsg
)
{
console
.
log
(
'
onUnhandledException, errorMsg:
'
+
JSON
.
stringify
(
errorMsg
));
}
};
errorManager
.
registerErrorObserver
(
observer
);
errorManager
.
on
(
'
error
'
,
observer
);
```
\ No newline at end of file
zh-cn/application-dev/reference/apis/js-apis-inner-application-eventHub.md
浏览文件 @
c6d74aec
...
...
@@ -12,7 +12,7 @@ EventHub模块提供了事件中心,提供订阅、取消订阅、触发事件
在使用eventHub的功能前,需要通过Ability实例的成员变量context获取。
```
ts
import
Ability
from
'
@ohos.app
lication.
Ability
'
;
import
Ability
from
'
@ohos.app
.ability.UI
Ability
'
;
export
default
class
MainAbility
extends
Ability
{
func1
(){
console
.
log
(
'
func1 is called
'
);
...
...
@@ -41,7 +41,7 @@ on(event: string, callback: Function): void;
**示例:**
```
ts
import
Ability
from
'
@ohos.app
lication.
Ability
'
;
import
Ability
from
'
@ohos.app
.ability.UI
Ability
'
;
export
default
class
MainAbility
extends
Ability
{
onForeground
()
{
...
...
@@ -79,7 +79,7 @@ off(event: string, callback?: Function): void;
**示例:**
```
ts
import
Ability
from
'
@ohos.app
lication.
Ability
'
;
import
Ability
from
'
@ohos.app
.ability.UI
Ability
'
;
export
default
class
MainAbility
extends
Ability
{
onForeground
()
{
...
...
@@ -117,7 +117,7 @@ emit(event: string, ...args: Object[]): void;
**示例:**
```
ts
import
Ability
from
'
@ohos.app
lication.
Ability
'
;
import
Ability
from
'
@ohos.app
.ability.UI
Ability
'
;
export
default
class
MainAbility
extends
Ability
{
onForeground
()
{
...
...
zh-cn/application-dev/reference/apis/js-apis-inner-application-missionListener.md
浏览文件 @
c6d74aec
...
...
@@ -31,8 +31,12 @@ let listener = {
onMissionMovedToFront
:
function
(
mission
)
{
console
.
log
(
'
onMissionMovedToFront mission:
'
+
JSON
.
stringify
(
mission
));
},
onMissionLabelUpdated
:
function
(
mission
)
{
console
.
log
(
'
onMissionLabelUpdated mission:
'
+
JSON
.
stringify
(
mission
));
},
onMissionIconUpdated
:
function
(
mission
,
icon
)
{
console
.
log
(
'
onMissionIconUpdated mission:
'
+
JSON
.
stringify
(
mission
));
console
.
log
(
'
onMissionIconUpdated icon:
'
+
JSON
.
stringify
(
icon
));
},
onMissionClosed
:
function
(
mission
)
{
console
.
log
(
'
onMissionClosed mission:
'
+
JSON
.
stringify
(
mission
));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录