Android(安卓)重启应用代码
16lz
2022-05-31
//重启应用 final Intent launchIntent = getApplication().getPackageManager().getLaunchIntentForPackage(getPackageName()); if (launchIntent != null) { UIUtils.showToastSafe("应用正在重启中请稍后..."); new Handler().postDelayed(new Runnable() { @Override public void run() { launchIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); startActivity(launchIntent); //添加activity切换动画效果 overridePendingTransition(0, 0); ActivityManager am = (ActivityManager) getSystemService(ACTIVITY_SERVICE); am.killBackgroundProcesses("你的包名"); android.os.Process.killProcess(android.os.Process.myPid()); System.exit(0); finish(); } },400);
更多相关文章
- Android屏幕横屏竖屏切换的方法
- android 对文件的操作模式
- android 第一次运行应用的引导界面
- Android打开关闭触摸提示音
- Android(安卓)spinner 动态添加时报错 java.lang.UnsupportedOpe
- Android开发指南整理
- android 利用TrafficStats类获取本应用的流量
- 【阿里云镜像】切换阿里巴巴开源镜像站镜像——Fedora镜像
- 【阿里云镜像】切换阿里巴巴开源镜像站镜像——Debian镜像