Exit/Finish an app/activity - android

前端 未结 12 770
醉梦人生
醉梦人生 2021-02-05 05:04

I\'ve got 4 activities say Act1, Act2, Act3 and Act4. A button in Act1 opens Act2, a button in Act2 opens Act3, a button in A

12条回答
  •  你的背包
    2021-02-05 05:52

    Intent intent = new Intent(Act4.this, Act1.class);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivity(intent);
    

    Clear the flag before you switch back to previous activity. It might help you.

提交回复
热议问题