How to close all the activities of my application?

后端 未结 4 1959
天涯浪人
天涯浪人 2020-11-29 04:23

I\'ve got an application with several activities, for example:

Activity 1 --> Activity 2 --> Activity 3 --> Activity 4

And I would like to close all the acti

4条回答
  •  温柔的废话
    2020-11-29 04:55

    And I would like to close all the activities from any activity

    That is user-hostile in Android. Please do not do that.

    and go back at home phone

    I have no idea what this means.

    If the user presses HOME, your activities can and should remain in RAM for a bit, in case the user returns to your application.

    If by "home phone" you mean that one of your activities is the "home" of the application, and you wish to return to that activity when the user presses some button or options menu item, call startActivity() with an Intent that:

    • identifies the activity you want to return to
    • has FLAG_ACTIVITY_CLEAR_TOP|FLAG_ACTIVITY_SINGLE_TOP in the flags, to indicate that you want to bring that activity forward and get rid of the other activities that the user had previously launched

提交回复
热议问题