Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
94f8e2c1
X
Xts Acts
项目概览
OpenHarmony
/
Xts Acts
1 年多 前同步成功
通知
9
Star
22
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
X
Xts Acts
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
94f8e2c1
编写于
7月 17, 2023
作者:
X
xinking129
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
modify code
Signed-off-by:
N
xinking129
<
xinxin13@huawei.com
>
上级
2c001841
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
23 addition
and
42 deletion
+23
-42
ability/ability_runtime/getrunningprocessinformation/ApplicationStateChangeOneReply/entry/src/main/ets/entryability/EntryAbility.ts
...eOneReply/entry/src/main/ets/entryability/EntryAbility.ts
+10
-19
ability/ability_runtime/getrunningprocessinformation/ApplicationStateChangeThreeReply/entry/src/main/ets/entryability/EntryAbility.ts
...hreeReply/entry/src/main/ets/entryability/EntryAbility.ts
+7
-13
ability/ability_runtime/getrunningprocessinformation/ApplicationStateChangeThreeReply/entry/src/main/ets/entryability1/EntryAbility1.ts
...eeReply/entry/src/main/ets/entryability1/EntryAbility1.ts
+3
-5
ability/ability_runtime/getrunningprocessinformation/ApplicationStateChangeTwoReply/entry/src/main/ets/entryability/EntryAbility.ts
...eTwoReply/entry/src/main/ets/entryability/EntryAbility.ts
+3
-5
未找到文件。
ability/ability_runtime/getrunningprocessinformation/ApplicationStateChangeOneReply/entry/src/main/ets/entryability/EntryAbility.ts
浏览文件 @
94f8e2c1
...
...
@@ -16,8 +16,7 @@ import hilog from '@ohos.hilog';
import
Ability
from
'
@ohos.app.ability.UIAbility
'
;
import
type
Window
from
'
@ohos.window
'
;
import
commonEvent
from
'
@ohos.commonEvent
'
;
const
ONE_SECOND
=
1000
;
const
FIVE_HUNDRED_MILLISECOND
=
500
;
const
VALID_STATE
=
1
;
const
INVALID_STATE
=
-
1
;
const
TAG
=
'
StateChangeTestTAG
'
;
...
...
@@ -33,12 +32,10 @@ let applicationStateChangeCallbackFir = {
console
.
log
(
TAG
,
'
applicationStateChangeCallbackFir onApplicationForeground
'
);
commonEventData
.
parameters
.
commonStateArr
[
0
]
=
VALID_STATE
;
setTimeout
(()
=>
{
console
.
info
(
'
Enter onApplicationForeground publish!
'
);
commonEvent
.
publish
(
'
processState
'
,
commonEventData
,
(
err
)
=>
{
console
.
info
(
'
====>processState publish err:
'
+
JSON
.
stringify
(
err
));
});
},
ONE_SECOND
);
console
.
info
(
'
Enter onApplicationForeground publish!
'
);
commonEvent
.
publish
(
'
processState
'
,
commonEventData
,
(
err
)
=>
{
console
.
info
(
'
====>processState publish err:
'
+
JSON
.
stringify
(
err
));
});
},
onApplicationBackground
()
{
console
.
log
(
TAG
,
'
applicationStateChangeCallbackFir onApplicationBackground
'
);
...
...
@@ -61,15 +58,11 @@ let applicationStateChangeCallbackSec = {
console
.
log
(
TAG
,
'
applicationStateChangeCallbackSec onApplicationBackground
'
);
commonEventData
.
parameters
.
commonStateArr
[
3
]
=
VALID_STATE
;
if
(
globalThis
.
want
.
action
===
'
doubleNeedBackGroundOff
'
)
{
setTimeout
(()
=>
{
globalThis
.
applicationContext
.
off
(
'
applicationStateChange
'
,
applicationStateChangeCallbackSec
);
},
FIVE_HUNDRED_MILLISECOND
);
globalThis
.
applicationContext
.
off
(
'
applicationStateChange
'
,
applicationStateChangeCallbackSec
);
}
else
if
(
globalThis
.
want
.
action
===
'
DoubleRegisterOff
'
)
{
setTimeout
(()
=>
{
console
.
info
(
'
entered DoubleRegisterOff
'
);
globalThis
.
applicationContext
.
off
(
'
applicationStateChange
'
);
},
FIVE_HUNDRED_MILLISECOND
);
console
.
info
(
'
entered DoubleRegisterOff
'
);
globalThis
.
applicationContext
.
off
(
'
applicationStateChange
'
);
}
}
}
...
...
@@ -132,11 +125,9 @@ export default class EntryAbility extends Ability {
onForeGroundTAG
++
;
if
(
onForeGroundTAG
===
VALID_STATE
&&
(
globalThis
.
want
.
action
===
'
NeedBackGroundOff
'
||
globalThis
.
want
.
action
===
'
MultiAppRegister
'
||
globalThis
.
want
.
action
===
'
DoubleRegisterOff
'
))
{
setTimeout
(()
=>
{
commonEvent
.
publish
(
'
processState
'
,
commonEventData
,
(
err
)
=>
{
commonEvent
.
publish
(
'
processState
'
,
commonEventData
,
(
err
)
=>
{
console
.
info
(
'
====>processState publish err:
'
+
JSON
.
stringify
(
err
));
})
},
2000
);
})
}
}
...
...
ability/ability_runtime/getrunningprocessinformation/ApplicationStateChangeThreeReply/entry/src/main/ets/entryability/EntryAbility.ts
浏览文件 @
94f8e2c1
...
...
@@ -17,8 +17,6 @@ import Ability from '@ohos.app.ability.UIAbility';
import
type
Window
from
'
@ohos.window
'
;
import
commonEvent
from
'
@ohos.commonEvent
'
;
const
ONE_SECOND
=
1000
;
const
THREE_SECOND
=
3000
;
const
VALID_STATE
=
1
;
const
INVALID_STATE
=
-
1
;
const
TAG
=
'
getRunningProcess
'
;
...
...
@@ -34,13 +32,11 @@ let applicationStateChangeCallbackFir = {
},
onApplicationBackground
()
{
console
.
log
(
TAG
,
'
applicationStateChangeCallbackFir onApplicationBackground
'
);
setTimeout
(()
=>
{
console
.
info
(
'
Enter onApplicationForeground publish!
'
);
commonEventData
.
parameters
.
commonStateArr
=
VALID_STATE
;
commonEvent
.
publish
(
'
processState
'
,
commonEventData
,
(
err
)
=>
{
console
.
info
(
'
====>processState publish err:
'
+
JSON
.
stringify
(
err
));
});
},
ONE_SECOND
);
console
.
info
(
'
Enter onApplicationForeground publish!
'
);
commonEventData
.
parameters
.
commonStateArr
=
VALID_STATE
;
commonEvent
.
publish
(
'
processState
'
,
commonEventData
,
(
err
)
=>
{
console
.
info
(
'
====>processState publish err:
'
+
JSON
.
stringify
(
err
));
});
}
};
let
foregroundTAG
=
INVALID_STATE
;
...
...
@@ -89,11 +85,9 @@ export default class EntryAbility extends Ability {
// Ability has brought to foreground
foregroundTAG
++
if
(
foregroundTAG
===
VALID_STATE
)
{
setTimeout
(()
=>
{
commonEvent
.
publish
(
'
processState
'
,
commonEventData
,
(
err
)
=>
{
commonEvent
.
publish
(
'
processState
'
,
commonEventData
,
(
err
)
=>
{
console
.
info
(
'
====>processState publish err:
'
+
JSON
.
stringify
(
err
));
})
},
THREE_SECOND
)
})
}
hilog
.
isLoggable
(
0x0000
,
'
testTag
'
,
hilog
.
LogLevel
.
INFO
);
...
...
ability/ability_runtime/getrunningprocessinformation/ApplicationStateChangeThreeReply/entry/src/main/ets/entryability1/EntryAbility1.ts
浏览文件 @
94f8e2c1
...
...
@@ -58,11 +58,9 @@ export default class EntryAbility1 extends Ability {
// Ability has brought to foreground
hilog
.
isLoggable
(
0x0000
,
'
testTag
'
,
hilog
.
LogLevel
.
INFO
);
hilog
.
info
(
0x0000
,
'
testTag
'
,
'
%{public}s
'
,
'
Ability onForeground
'
);
setTimeout
(()
=>
{
globalThis
.
abilityContext2
.
terminateSelf
((
err
)
=>
{
console
.
log
(
'
terminateSelf result:
'
+
JSON
.
stringify
(
err
));
});
},
3000
);
globalThis
.
abilityContext2
.
terminateSelf
((
err
)
=>
{
console
.
log
(
'
terminateSelf result:
'
+
JSON
.
stringify
(
err
));
});
}
onBackground
()
{
...
...
ability/ability_runtime/getrunningprocessinformation/ApplicationStateChangeTwoReply/entry/src/main/ets/entryability/EntryAbility.ts
浏览文件 @
94f8e2c1
...
...
@@ -73,11 +73,9 @@ export default class EntryAbility extends Ability {
// Ability has brought to foreground
hilog
.
isLoggable
(
0x0000
,
'
testTag
'
,
hilog
.
LogLevel
.
INFO
);
hilog
.
info
(
0x0000
,
'
testTag
'
,
'
%{public}s
'
,
'
Ability onForeground
'
);
setTimeout
(()
=>
{
globalThis
.
abilityContext
.
terminateSelf
((
err
)
=>
{
console
.
log
(
'
terminateSelf result:
'
+
JSON
.
stringify
(
err
));
});
},
3000
);
globalThis
.
abilityContext
.
terminateSelf
((
err
)
=>
{
console
.
log
(
'
terminateSelf result:
'
+
JSON
.
stringify
(
err
));
});
}
onBackground
()
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录