harmony 鸿蒙Ability Subsystem Changelog
Ability Subsystem Changelog
cl.ability.1 API restartApp Changed
Access Level
Public API
Reason for Change
The change is made to prevent malicious applications from restarting themselves when they do not gain focus.
Change Impact
This change is a non-compatible change. An application should call the restartApp API when it is in the focus state. Otherwise, functions will be affected.
Start API Level
12
Change Since
OpenHarmony SDK 5.0.0.31
Adaptation Guide
Call the restartApp API when the application is in the focus state.
Example
import { UIAbility, Want } from '@kit.AbilityKit';
export default class MyAbility extends UIAbility {
onForeground() {
let applicationContext = this.context.getApplicationContext();
let want: Want = {
bundleName: 'com.example.myapp',
abilityName: 'EntryAbility'
};
try {
applicationContext.restartApp(want);
} catch (error) {
console.error(`restartApp fail, error: ${JSON.stringify(error)}`);
}
}
}
你可能感兴趣的鸿蒙文章
harmony 鸿蒙ArkCompiler Subsystem Changelog
harmony 鸿蒙Bundle Manager Subsystem Changelog
harmony 鸿蒙Notification Subsystem ChangeLog
0
赞
- 所属分类: 后端技术
- 本文标签:
热门推荐
-
2、 - 优质文章
-
3、 gate.io
-
7、 golang
-
9、 openharmony
-
10、 Vue中input框自动聚焦