B
B
BitNeBolt2020-05-16 21:48:29
Android
BitNeBolt, 2020-05-16 21:48:29

How to continue the method when the activity is in onStop()?

This resource is written about the behavior of objects in the life cycle of an activity:

Quote

Когда ваша активность останавливается, объекты активности хранятся в памяти и восстанавливаются, когда активность возобновляет свою работу. Вам не нужно повторно инициализировать компоненты, которые были созданы ранее. Кроме того, система отслеживает текущее состояние для каждого представления, поэтому, если пользователь введёт текст в текстовое поле, то его содержание сохраняется и вам не нужно сохранять и восстанавливать его.



So. I have a separate class that implements LocationListener. It is created in this activity and starts sending requests. When the screen is on, everything works well, if it is blocked, then there is no new information. I solved the problem by forbidding the firmware on the phone to save charge on this application, everything began to work fine.

How can I make the class work in the background, even when the activity is closed, without using services and so that it is not necessary to disable power saving in the settings?

PS I tried and make 1 instance of this class in Application, but there were similar results. A similar program works with the screen turned off and energy saving turned on, so I wanted to implement this.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Korotenko, 2020-05-16
@BitNeBolt

Services maybe your way.
https://developer.android.com/guide/components/ser...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question