index.uts 841 B

123456789101112131415161718192021222324
  1. import type { RestartApp, ExitApp } from "../interface.uts";
  2. import type { common, Want } from '@kit.Abilitykit';
  3. import bundleManager from '@ohos.bundle.bundleManager';
  4. import { process } from '@kit.ArkTS';
  5. // export const reStartApp : RestartApp = () => {
  6. // const context = UTSHarmony.getUIAbilityContext() as common.UIAbilityContext
  7. // let applicationContext = context.getApplicationContext();
  8. // let request : Want = {
  9. // bundleName: bundleManager.getBundleInfoForSelfSync(bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT).name // 加载当前包名
  10. // }
  11. // try {
  12. // applicationContext.restartApp(request);
  13. // } catch (error) {
  14. // console.error(`restartApp fail, error: ${JSON.stringify(error)}`);
  15. // }
  16. // }
  17. //退出应用
  18. export const exitApp : ExitApp = () => {
  19. let pro = new process.ProcessManager();
  20. pro.exit(0);
  21. }