Answer the question
In order to leave comments, you need to log in
Lifecycle onResume() as a place for all operations related to user action with current Activity?
Do I understand correctly that all operations associated with a user action with the current Activity (for example, pressing a button) should be written in the Activity life cycle onResume()
, since it is in this life cycle that the Activity is visible to the user and can be interacted with?
Answer the question
In order to leave comments, you need to log in
You can write the logic where it suits you, I put button handlers in onCreate().
The onCreate() and onResume() methods are very similar but have a slight difference. onStart() is called when the Activity is ready, and onResume() when it is resumed. Read about the Activity lifecycle. And what to prescribe where depends on the logic of the application. If you need to count the number of screen impressions, then there will be differences, depending on where you set the increment:
onResume(): Запуск+1, свернул-развернул приложение+1, показал-скрыл диалоговое окно+1
onStart(): Запуск+1, свернул-развернул приложение+1, показал-скрыл диалоговое окно+0
onCreate(): Запуск+1, свернул-развернул приложение+0, показал-скрыл диалоговое окно+0
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question