Android remove Activity from back stack

后端 未结 11 2081
予麋鹿
予麋鹿 2020-12-07 17:23

Okay so I\'m kind of stumped on what to do with this. So I have the MainActivity, and from there an Activity can be launched to DegreePlanActivity, and from there another Ac

11条回答
  •  情书的邮戳
    2020-12-07 17:55

    Here is your flow:

    MainActivity --> DegreePlanActivty --> EditDegreePlan--> DegreePlan --> MainActivty

    Override these method inside your "DegreePlan"

    public void onBackPressed() {
       super.onBackPressed();
       Intent goToMainActivity = new Intent(getApplicationContext(), MainActivity.class);
       goToMainActivity.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); // Will clear out your activity history stack till now
       startActivity(goToMainActivity);
    }
    

提交回复
热议问题