Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
ed84c4a8
D
Docs
项目概览
OpenHarmony
/
Docs
大约 1 年 前同步成功
通知
159
Star
292
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
ed84c4a8
编写于
2月 28, 2023
作者:
M
mingxihua
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
mingxihua@huawei.com.cn
Signed-off-by:
N
mingxihua
<
mingxihua@huawei.com
>
上级
4a4cf974
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
95 addition
and
51 deletion
+95
-51
zh-cn/application-dev/reference/apis/js-apis-ability-featureAbility.md
...tion-dev/reference/apis/js-apis-ability-featureAbility.md
+49
-21
zh-cn/application-dev/reference/apis/js-apis-ability-particleAbility.md
...ion-dev/reference/apis/js-apis-ability-particleAbility.md
+20
-12
zh-cn/application-dev/reference/apis/js-apis-application-configuration.md
...n-dev/reference/apis/js-apis-application-configuration.md
+2
-2
zh-cn/application-dev/reference/apis/js-apis-inner-application-applicationContext.md
...ence/apis/js-apis-inner-application-applicationContext.md
+20
-12
zh-cn/application-dev/reference/apis/js-apis-inner-application-uiAbilityContext.md
...erence/apis/js-apis-inner-application-uiAbilityContext.md
+4
-4
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-ability-featureAbility.md
浏览文件 @
ed84c4a8
...
...
@@ -57,8 +57,12 @@ featureAbility.startAbility(
uri
:
''
},
},
(
err
,
data
)
=>
{
console
.
info
(
'
startAbility err: ${JSON.stringify(err)}, data: ${JSON.stringify(data)}
'
);
(
error
,
data
)
=>
{
if
(
error
&&
error
.
code
!==
0
)
{
console
.
error
(
'
startAbility fail, error: ${JSON.stringify(error)}
'
);
}
else
{
console
.
log
(
'
startAbility success, data: ${JSON.stringify(data)}
'
);
}
}
);
```
...
...
@@ -193,8 +197,12 @@ featureAbility.startAbilityForResult(
uri
:
''
},
},
(
err
,
data
)
=>
{
console
.
info
(
'
startAbilityForResult err: ${JSON.stringify(err)}, data: ${JSON.stringify(data)}
'
);
(
error
,
data
)
=>
{
if
(
error
&&
error
.
code
!==
0
)
{
console
.
error
(
'
startAbilityForResult fail, error: ${JSON.stringify(error)}
'
);
}
else
{
console
.
log
(
'
startAbilityForResult success, data: ${JSON.stringify(data)}
'
);
}
}
);
```
...
...
@@ -309,8 +317,8 @@ featureAbility.terminateSelfWithResult(
}
},
},
(
err
)
=>
{
console
.
error
(
'
err
: ${JSON.stringify(er
r)}
'
);
(
err
or
)
=>
{
console
.
error
(
'
err
or: ${JSON.stringify(erro
r)}
'
);
}
);
```
...
...
@@ -389,8 +397,12 @@ hasWindowFocus(callback: AsyncCallback\<boolean>): void
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
featureAbility
.
hasWindowFocus
((
err
,
data
)
=>
{
console
.
info
(
'
hasWindowFocus err: ${JSON.stringify(err)}, data: ${JSON.stringify(data)}
'
);
featureAbility
.
hasWindowFocus
((
error
,
data
)
=>
{
if
(
error
&&
error
.
code
!==
0
)
{
console
.
error
(
'
hasWindowFocus fail, error: ${JSON.stringify(error)}
'
);
}
else
{
console
.
log
(
'
hasWindowFocus success, data: ${JSON.stringify(data)}
'
);
}
});
```
...
...
@@ -435,8 +447,12 @@ getWant(callback: AsyncCallback\<Want>): void
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
featureAbility
.
getWant
((
err
,
data
)
=>
{
console
.
info
(
'
getWant err: ${JSON.stringify(err)}, data: ${JSON.stringify(data)}
'
);
featureAbility
.
getWant
((
error
,
data
)
=>
{
if
(
error
&&
error
.
code
!==
0
)
{
console
.
error
(
'
getWant fail, error: ${JSON.stringify(error)}
'
);
}
else
{
console
.
log
(
'
getWant success, data: ${JSON.stringify(data)}
'
);
}
});
```
...
...
@@ -482,8 +498,12 @@ getContext(): Context
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
let
context
=
featureAbility
.
getContext
();
context
.
getBundleName
((
err
,
data
)
=>
{
console
.
info
(
'
getBundleName err: ${JSON.stringify(err)}, data: ${JSON.stringify(data)}
'
);
context
.
getBundleName
((
error
,
data
)
=>
{
if
(
error
&&
error
.
code
!==
0
)
{
console
.
error
(
'
getBundleName fail, error: ${JSON.stringify(error)}
'
);
}
else
{
console
.
log
(
'
getBundleName success, data: ${JSON.stringify(data)}
'
);
}
});
```
...
...
@@ -506,8 +526,8 @@ terminateSelf(callback: AsyncCallback\<void>): void
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
featureAbility
.
terminateSelf
(
(
err
)
=>
{
console
.
error
(
'
err
: ${JSON.stringify(er
r)}
'
);
(
err
or
)
=>
{
console
.
error
(
'
err
or: ${JSON.stringify(erro
r)}
'
);
}
)
```
...
...
@@ -574,7 +594,7 @@ function onDisconnectCallback(element){
console
.
log
(
'
ConnectAbility onDisconnect element.deviceId : ${element.deviceId}
'
)
}
function
onFailedCallback
(
code
){
console
.
log
(
'
featureAbilityTest ConnectAbility onFailed errCode : ${code}
'
)
console
.
error
(
'
featureAbilityTest ConnectAbility onFailed errCode : ${code}
'
)
}
let
connectId
=
featureAbility
.
connectAbility
(
{
...
...
@@ -617,7 +637,7 @@ function onDisconnectCallback(element){
console
.
log
(
'
ConnectAbility onDisconnect element.deviceId : ${element.deviceId}
'
);
}
function
onFailedCallback
(
code
){
console
.
log
(
'
featureAbilityTest ConnectAbility onFailed errCode : ${code}
'
);
console
.
error
(
'
featureAbilityTest ConnectAbility onFailed errCode : ${code}
'
);
}
let
connectId
=
featureAbility
.
connectAbility
(
{
...
...
@@ -631,8 +651,12 @@ let connectId = featureAbility.connectAbility(
},
);
featureAbility
.
disconnectAbility
(
connectId
,
(
err
)
=>
{
console
.
error
(
'
featureAbilityTest disconnectAbility err: ${JSON.stringify(err)}
'
);
featureAbility
.
disconnectAbility
(
connectId
,
(
error
)
=>
{
if
(
error
&&
error
.
code
!==
0
)
{
console
.
error
(
'
disconnectAbility fail, connectId: ${connectId}, error: ${JSON.stringify(error)}
'
);
}
else
{
console
.
log
(
'
disconnectAbility success, connectId: ${connectId}
'
);
}
});
```
...
...
@@ -668,7 +692,7 @@ function onDisconnectCallback(element){
console
.
log
(
'
ConnectAbility onDisconnect element.deviceId : ${element.deviceId}
'
);
}
function
onFailedCallback
(
code
){
console
.
log
(
'
featureAbilityTest ConnectAbility onFailed errCode : ${code}
'
);
console
.
error
(
'
featureAbilityTest ConnectAbility onFailed errCode : ${code}
'
);
}
let
connectId
=
featureAbility
.
connectAbility
(
{
...
...
@@ -707,8 +731,12 @@ getWindow(callback: AsyncCallback\<window.Window>): void
**示例:**
```
ts
featureAbility
.
getWindow
((
err
,
data
)
=>
{
console
.
info
(
'
getWindow err: ${JSON.stringify(err)}, data: ${typeof(data)}
'
);
featureAbility
.
getWindow
((
error
,
data
)
=>
{
if
(
error
&&
error
.
code
!==
0
)
{
console
.
error
(
'
getWindow fail, error: ${JSON.stringify(error)}
'
);
}
else
{
console
.
log
(
'
getWindow success, data: ${JSON.stringify(data)}
'
);
}
});
```
...
...
zh-cn/application-dev/reference/apis/js-apis-ability-particleAbility.md
浏览文件 @
ed84c4a8
...
...
@@ -57,8 +57,12 @@ particleAbility.startAbility(
uri
:
''
},
},
(
error
,
result
)
=>
{
console
.
error
(
'
particleAbility startAbility errCode: ${JSON.stringify(error)}, result: ${JSON.stringify(result)}
'
);
(
error
,
data
)
=>
{
if
(
error
&&
error
.
code
!==
0
)
{
console
.
error
(
'
startAbility fail, error: ${JSON.stringify(error)}
'
);
}
else
{
console
.
log
(
'
startAbility success, data: ${JSON.stringify(data)}
'
);
}
},
);
```
...
...
@@ -133,8 +137,12 @@ terminateSelf(callback: AsyncCallback\<void>): void
import
particleAbility
from
'
@ohos.ability.particleAbility
'
;
particleAbility
.
terminateSelf
(
(
error
,
result
)
=>
{
console
.
log
(
'
particleAbility terminateSelf errCode: ${JSON.stringify(error)}, result: ${JSON.stringify(result)}
'
);
(
error
,
data
)
=>
{
if
(
error
&&
error
.
code
!==
0
)
{
console
.
error
(
'
terminateSelf fail, error: ${JSON.stringify(error)}
'
);
}
else
{
console
.
log
(
'
terminateSelf success, data: ${JSON.stringify(data)}
'
);
}
}
);
```
...
...
@@ -226,11 +234,11 @@ import notification from '@ohos.notification';
import
particleAbility
from
'
@ohos.ability.particleAbility
'
;
import
wantAgent
from
'
@ohos.app.ability.wantAgent
'
;
function
callback
(
err
,
data
)
{
if
(
err
)
{
console
.
error
(
'
Operation failed
cause: ${JSON.stringify(er
r)}
'
);
function
callback
(
err
or
,
data
)
{
if
(
err
or
&&
error
.
code
!==
0
)
{
console
.
error
(
'
Operation failed
error: ${JSON.stringify(erro
r)}
'
);
}
else
{
console
.
info
(
'
Operation succeeded
'
);
console
.
info
(
'
Operation succeeded
, data: ${data}
'
);
}
}
...
...
@@ -349,11 +357,11 @@ cancelBackgroundRunning(callback: AsyncCallback<void>): void;
```
ts
import
particleAbility
from
'
@ohos.ability.particleAbility
'
;
function
callback
(
err
,
data
)
{
if
(
err
)
{
console
.
error
(
'
Operation failed
cause: ${JSON.stringify(er
r)}
'
);
function
callback
(
err
or
,
data
)
{
if
(
err
or
&&
error
.
code
!==
0
)
{
console
.
error
(
'
Operation failed
error: ${JSON.stringify(erro
r)}
'
);
}
else
{
console
.
info
(
'
Operation succeeded
'
);
console
.
info
(
'
Operation succeeded
, data: ${data}
'
);
}
}
...
...
zh-cn/application-dev/reference/apis/js-apis-application-configuration.md
浏览文件 @
ed84c4a8
...
...
@@ -41,10 +41,10 @@ export default class EntryAbility extends UIAbility {
windowStage
.
loadContent
(
'
pages/index
'
,
(
err
,
data
)
=>
{
if
(
err
.
code
)
{
console
.
error
(
'
failed to load the content, error:
+
${JSON.stringify(err)}
'
);
console
.
error
(
'
failed to load the content, error: ${JSON.stringify(err)}
'
);
return
;
}
console
.
info
(
'
Succeeded in loading the content, data:
+
${JSON.stringify(data)}
'
);
console
.
info
(
'
Succeeded in loading the content, data: ${JSON.stringify(data)}
'
);
});
}
}
...
...
zh-cn/application-dev/reference/apis/js-apis-inner-application-applicationContext.md
浏览文件 @
ed84c4a8
...
...
@@ -83,7 +83,7 @@ export default class EntryAbility extends UIAbility {
let
applicationContext
=
this
.
context
.
getApplicationContext
();
// 2.通过applicationContext注册监听应用内生命周期
lifecycleId
=
applicationContext
.
on
(
'
abilityLifecycle
'
,
AbilityLifecycleCallback
);
console
.
log
(
'
registerAbilityLifecycleCallback
number:
'
+
JSON
.
stringify
(
lifecycleId
)
);
console
.
log
(
'
registerAbilityLifecycleCallback
lifecycleId: ${lifecycleId)}
'
);
}
}
```
...
...
@@ -114,9 +114,13 @@ let lifecycleId;
export
default
class
EntryAbility
extends
UIAbility
{
onDestroy
()
{
let
applicationContext
=
this
.
context
.
getApplicationContext
();
console
.
log
(
'
stage applicationContext:
'
+
applicationContext
);
console
.
log
(
'
stage applicationContext:
${applicationContext}
'
);
applicationContext
.
off
(
type
:
'
abilityLifecycle
'
,
lifecycleId
,
(
error
,
data
)
=>
{
console
.
log
(
'
unregisterAbilityLifecycleCallback success, err:
'
+
JSON
.
stringify
(
error
));
if
(
error
&&
error
.
code
!==
0
)
{
console
.
error
(
'
unregisterAbilityLifecycleCallback fail, err: ${JSON.stringify(error)}
'
);
}
else
{
console
.
log
(
'
unregisterAbilityLifecycleCallback success, data: ${JSON.stringify(data)}
'
);
}
});
}
}
...
...
@@ -147,7 +151,7 @@ let lifecycleId;
export
default
class
MyAbility
extends
Ability
{
onDestroy
()
{
let
applicationContext
=
this
.
context
.
getApplicationContext
();
console
.
log
(
'
stage applicationContext:
'
+
applicationContext
);
console
.
log
(
'
stage applicationContext:
${applicationContext}
'
);
applicationContext
.
off
(
type
:
'
abilityLifecycle
'
,
lifecycleId
);
}
}
...
...
@@ -185,19 +189,19 @@ 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
)
);
console
.
log
(
'
onConfigurationUpdated config:
${JSON.stringify(config)}
'
);
},
onMemoryLevel
(
level
){
console
.
log
(
'
onMemoryLevel level:
'
+
level
);
console
.
log
(
'
onMemoryLevel level:
${level}
'
);
}
}
}
;
// 1.获取applicationContext
let
applicationContext
=
globalThis
.
applicationContext
;
// 2.通过applicationContext注册监听
应用内生命周期
callbackId
=
applicationContext
.
on
(
'
environment
'
,
E
nvironmentCallback
);
console
.
log
(
'
registerEnvironmentCallback
number:
'
+
JSON
.
stringify
(
callbackId
)
);
// 2.通过applicationContext注册监听
系统环境变化
callbackId
=
applicationContext
.
on
(
'
environment
'
,
e
nvironmentCallback
);
console
.
log
(
'
registerEnvironmentCallback
callbackId: ${callbackId}
'
);
}
}
```
...
...
@@ -229,7 +233,11 @@ export default class EntryAbility extends UIAbility {
onDestroy
()
{
let
applicationContext
=
this
.
context
.
getApplicationContext
();
applicationContext
.
off
(
'
environment
'
,
callbackId
,
(
error
,
data
)
=>
{
console
.
log
(
'
unregisterEnvironmentCallback success, err:
'
+
JSON
.
stringify
(
error
));
if
(
error
&&
error
.
code
!==
0
)
{
console
.
error
(
'
unregisterEnvironmentCallback fail, err: ${JSON.stringify(error)}
'
);
}
else
{
console
.
log
(
'
unregisterEnvironmentCallback success, data: ${JSON.stringify(data)}
'
);
}
});
}
}
...
...
zh-cn/application-dev/reference/apis/js-apis-inner-application-uiAbilityContext.md
浏览文件 @
ed84c4a8
...
...
@@ -1916,7 +1916,7 @@ setMissionLabel(label: string): Promise<void>;
setMissionIcon(icon: image.PixelMap, callback:AsyncCallback
\<
void>): void;
设置当前ability在任务中显示的图标(callback形式)。
设置当前ability在任务中显示的图标
, 图标大小最大为600M
(callback形式)。
**系统能力**
:SystemCapability.Ability.AbilityRuntime.Core
...
...
@@ -1966,7 +1966,7 @@ setMissionIcon(icon: image.PixelMap, callback:AsyncCallback\<void>): void;
setMissionIcon(icon: image.PixelMap): Promise
\<
void>;
设置当前ability在任务中显示的图标(promise形式)。
设置当前ability在任务中显示的图标
, 图标大小最大为600M
(promise形式)。
**系统能力**
:SystemCapability.Ability.AbilityRuntime.Core
...
...
@@ -2112,7 +2112,7 @@ try {
return
;
}
// 执行正常业务
console
.
info
(
'
requestDialogService succeed, result =
'
+
JSON
.
stringify
(
result
)
);
console
.
info
(
'
requestDialogService succeed, result =
${JSON.stringify(result)}
'
);
});
}
catch
(
err
)
{
// 处理入参错误异常
...
...
@@ -2160,7 +2160,7 @@ try {
this
.
context
.
requestDialogService
(
want
)
.
then
((
result
)
=>
{
// 执行正常业务
console
.
info
(
'
requestDialogService succeed, result =
'
+
JSON
.
stringify
(
result
)
);
console
.
info
(
'
requestDialogService succeed, result =
${JSON.stringify(result)}
'
);
})
.
catch
((
err
)
=>
{
// 处理业务逻辑错误
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录