Unable to close all activities on android eclipse

后端 未结 4 1975
眼角桃花
眼角桃花 2020-12-06 09:06

Assume i have four classes.Each class is having a button to do screen switching from one page to another page,well its working fine.But now im trying to close all the activi

4条回答
  •  醉话见心
    2020-12-06 09:24

    Simply try this. Consider your Class3.java is your last Activitiy And, in Button of next use below code -

    Intent intent = new Intent(currentActivity.this, XitActivity.class); // instead of XitActivity use your first activity
    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    intent.putExtra("EXIT", true);
    startActivity(intent);
    

    And, in your Xit_demoActivity's onCreate() use below code -

    if (getIntent().getBooleanExtra("EXIT", false)) {
        finish();
    }
    

    Hope this will helps you to exit you from all activities.

提交回复
热议问题