Perhaps a stupid question, but how to close the Activity correctly:
before the launch of the new activation
finish(); startActivity...; or after
startActivity... finish(); Perhaps a stupid question, but how to close the Activity correctly:
before the launch of the new activation
finish(); startActivity...; or after
startActivity... finish(); Actually, it makes no difference. All the same, these methods are not direct (immediate), but will be executed in reality only after they fall into the MessageQueue message processing queue , which is executed in the UI Thread - in the so-called MainLooper ( Looper.getMainLooper() )
In fact, the call to finish() and startActivity() , as well as any actions with the window system a la setText() will be translated into messages that Looper will process - approximately as in the picture:
From this point of view, the sequence does not matter.
startActivity() Activity will be destroyed, before which finish() was called. That is, if the methods were direct actions, then such behavior would lead to a collapse, roughly speaking, it would not have been possible to first destroy, and then cause something from the destroyed instance ... Something like this. - BarmaleySource: https://ru.stackoverflow.com/questions/757824/
All Articles