1# Ability Subsystem Changelog
2
3## cl.ability.1 API restartApp Changed
4
5**Access Level**
6
7Public API
8
9**Reason for Change**
10
11The change is made to prevent malicious applications from restarting themselves when they do not gain focus.
12
13**Change Impact**
14
15This 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.
16
17**Start API Level**
18
1912
20
21**Change Since**
22
23OpenHarmony SDK 5.0.0.31
24
25**Adaptation Guide**
26
27Call the **restartApp** API when the application is in the focus state.
28
29**Example**
30
31```ts
32import { UIAbility, Want } from '@kit.AbilityKit';
33
34export default class MyAbility extends UIAbility {
35  onForeground() {
36    let applicationContext = this.context.getApplicationContext();
37    let want: Want = {
38      bundleName: 'com.example.myapp',
39      abilityName: 'EntryAbility'
40    };
41    try {
42      applicationContext.restartApp(want);
43    } catch (error) {
44      console.error(`restartApp fail, error: ${JSON.stringify(error)}`);
45    }
46  }
47}
48```
49