Finish parent and current activity in Android

前端 未结 16 3087
误落风尘
误落风尘 2020-11-27 03:40

I have 3 activities. Activity A which leads to activity B, which in turn can go back to activity A or start activity C. However, if I press back in activity C the app should

16条回答
  •  再見小時候
    2020-11-27 04:19

    From the screen(B) you want to start the screen(C) with NO back screen, just start this screen (C) with:

    screenC.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP 
        | Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP);
    startActivity(screenC);
    finish();
    

    The back in screenC will exit the application.

提交回复
热议问题