restartApp在应用非获焦时无法使用

restartApp在应用非获焦时无法使用

HarmonyOS
2024-08-01 09:35:41
625浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
橱柜里的蛙

restartApp接口发生了变更,变更之后方法需要在应用处于获焦状态时使用

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)}`);
    }
  }
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
分享
微博
QQ
微信
回复
2024-08-01 18:18:27


相关问题
应用通用及走方式如何实现
2803浏览 • 1回复 待解决
HarmonyOS RichEditor /失问题
1128浏览 • 1回复 待解决
HarmonyOS TextInput意外
963浏览 • 1回复 待解决
HarmonyOS dialog组件类中无法弹出
887浏览 • 1回复 待解决
HarmonyOS 弹框无法组件里面弹出
656浏览 • 1回复 待解决
H5页面输入框自动弹起软键盘
2775浏览 • 1回复 待解决
如何判断应用使用流量网络wifi
1336浏览 • 1回复 待解决
HarmonyOS appRecovery.restartApp无效
1098浏览 • 1回复 待解决
HarmonyOS appRecovery.restartApp()方法无效
507浏览 • 1回复 待解决