public class MyApplication extends Application {
private static MyApplication mInstance;
private static List<Activity> activityList = new LinkedList<Activity>();
@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 注销到登陆界面实现
最新推荐文章于 2024-08-13 08:12:56 发布