S
S
Sevak Avetisyan2015-01-27 17:08:14
Android
Sevak Avetisyan, 2015-01-27 17:08:14

Activity lifecycle control?

Good day! There is an application for the university schedule , in which there are 5 activities (see diagram):
8ed7b7743806484ea967e100a6aac926.png
The main activity is schedule, if the user launches the application for the first time, then he follows this path: departments => groups => schedule, otherwise immediately schedule. There are 2 items in the settings activity, when you click on one of them, the favorite list is erased, and the second allows you to change your group, launches the departments => groups => schedule activity. I want to do the following: if the user is in the schedule activity, i.e. Most importantly, by pressing the "back" button, he will exit the application, no matter what happened in the application before, roughly speaking, so that the application life cycle is limited to the transitions indicated in the diagram. I tried storing activity instances and calling .finish(), but this is probably the worst way! It often happened that if you minimize the application on some activity (not the main one), and then expand it, then everything crashed. How can I do what I want?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
IceJOKER, 2015-01-27
@IceJOKER

In the main activity, override the onbackpressed method and call finish.
and open the main activity with the flag Intent.FLAG_ACTIVITY_CLEAR_TOP
Not sure, but you can try)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question