1、杀进程

android.os.Process.killProcess(android.os.Process.myPid());


2、系统退出

System.exit(0);

3、activity管理

ActivityManager activityManager = (ActivityManager) TestLogout.this .getSystemService(Context.ACTIVITY_SERVICE);

activityManager.killBackgroundProcesses(getPackageName());



4、清除栈

Intent intent = new Intent();
intent.setClass(Logout.this, Logout.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.putExtra("flag", 1);
startActivity(intent);



5、显示桌面

Intent startMain = new Intent(Intent.ACTION_MAIN);
startMain.addCategory(Intent.CATEGORY_HOME);
startMain.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(startMain);


还可以建立Activity列表,在每个Activity创建的时候加入列表;在退出时,遍历列表,逐一activity.finish()。

以上几种方法可以组合使用,达到最终需要的效果。



更多相关文章

  1. Android 列表之分组ListView
  2. android dpi换算以及常用分辨率列表
  3. Android 自定义分享列表ACTION_SEND
  4. Android | activity之间传递列表,以listview显示
  5. android最近任务列表,删除某个应用操作
  6. Android 的res/values/colors自定义颜色列表和注释表及布局文件
  7. 【Android】ExpandableListView二级列表使用介绍
  8. android2.3 api demo 学习系列(1)--apidemo主列表的实现

随机推荐

  1. Android -- 倒计时Button的实现
  2. Android 发布版本不输出Log
  3. android 动态布局setLayoutParams方法设
  4. android加载本地图片
  5. 我的Android计算器
  6. xproto xextproto xtrans xcb >= 1.1.92
  7. Android中的那些sql语句
  8. 复习android SQLiteOpenHelper
  9. Android关闭输入法
  10. Android 获取当前进程