123456789101112131415161718192021222324 |
- import type { RestartApp, ExitApp } from "../interface.uts";
- import type { common, Want } from '@kit.Abilitykit';
- import bundleManager from '@ohos.bundle.bundleManager';
- import { process } from '@kit.ArkTS';
- // export const reStartApp : RestartApp = () => {
- // const context = UTSHarmony.getUIAbilityContext() as common.UIAbilityContext
- // let applicationContext = context.getApplicationContext();
- // let request : Want = {
- // bundleName: bundleManager.getBundleInfoForSelfSync(bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT).name // 加载当前包名
- // }
- // try {
- // applicationContext.restartApp(request);
- // } catch (error) {
- // console.error(`restartApp fail, error: ${JSON.stringify(error)}`);
- // }
- // }
- //退出应用
- export const exitApp : ExitApp = () => {
- let pro = new process.ProcessManager();
- pro.exit(0);
- }
|