Android完全退出应用程序的方法
16lz
2021-01-23
一、第一种:[此方法在Android 2.2有效]
IntentstartMain = new Intent(Intent.ACTION_MAIN);startMain.addCategory(Intent.CATEGORY_HOME);
startMain.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(startMain);
System.exit( 0 ); // 退出程序
二、第二种:【此方法在Android 1.5—Android 2.1有效】
1、在配置文件中加入权限:
<uses-permission android:name="android.permission.RESTART_PACKAGES" />
2、
ActivityManager am = (ActivityManager)getSystemService (Context.ACTIVITY_SERVICE);
am.restartPackage(getPackageName());
更多相关文章
- android获取mac地址方法
- ListView多次调用getView方法
- Android定位问题方法
- android获取设备屏幕分辨率的方法
- Android 在Activity中获取控件尺寸的方法
- android中的ListView的使用方法
- 【android开发】之【android动态布局方法总结】
- Android 通过接口的方式去调用服务里面的方法
- android的ndk修改app_platform的方法,亲测绝对可行