彻底关闭应用程序 要点
?根据Activity的声明周期
???我们知道Android的窗口类提供了历史栈,我们可以通过stack的原理来巧妙的实现,这里我们在A窗口打开B窗口时在Intent中直接加入标志Intent.FLAG_ACTIVITY_CLEAR_TOP,这样开启B时将会清除该进程空间的所有Activity。
?在A窗口中使用下面的代码调用B窗口
Intent intent = new Intent();?
intent.setClass(Android123.this, CWJ.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);? //注意本行的FLAG设置
startActivity(intent);