W
W
Who_Is_Who2018-11-18 17:27:16
Java
Who_Is_Who, 2018-11-18 17:27:16

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

2 answer(s)
E
Egor, 2018-11-19
@Who_Is_Who

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

E
Elmo Sputterspark, 2018-11-18
@Sputterspark

No, not right.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question