修改密码后退回到登录界面,再按返回键退出应用,关闭所有的Activity

在Application中写如下代码:

public class MyApplication extends Application {

    private static MyApplication mInstance;
    private int speedGrade = 1;
    private List<Activity> activityList=new LinkedList<Activity>();
public static MyApplication getInstance() {
if(mInstance==null){
 mInstance=new Myapplication;

} else{

return mInstance; 

}

}

public void addActivity(Activity activity){ 

activityList.add(activity);

public void exit(){ 

for(Activity activity:activityList){

 activity.finish(); 

}

 //System.exit(0);//此句加了之后再退出时会有黑屏闪现,去掉则无此现象;

 }

 
 


在其他的activity中调用MyApplication.getInstance().addActivity(***activity)使其加入列表。 然后在要退出的按钮等事件监听中调用MyApplication.getInstance().exit()就行了!

你可能感兴趣的:(修改密码后退回到登录界面,再按返回键退出应用,关闭所有的Activity)