android 注销到登陆界面实现

 
   
   
   
   
public class MyApplication extends Application {
    private static MyApplication mInstance;
    private static List activityList = new LinkedList();
    @Override
    public void onCreate() {
        super.onCreate();
        mInstance = this;
    }

    public static MyApplication getInstance() {
        return mInstance;
    }

    public void addActivity(Activity activity)  {
        activityList.add(activity);
    }
    public void removeActivity(Activity activity){
        activityList.remove(activity);
    }
    public void exitAllActivity(){
        for(Activity activity:activityList) {
            activity.finish();
        }
    }
}
public class BaseActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        MyApplication.getInstance().addActivity(this);
    }
    @Override
    protected void onDestroy() {
        super.onDestroy();
        MyApplication.getInstance().removeActivity(this);
    }
}

退出登录

MyApplication.getInstance().exitAllActivity();
startActivity(new Intent(this,LoginActivity.class));

你可能感兴趣的:(android 注销到登陆界面实现)