[Interest] android: auto shutdown main process if is in background during some time

Alexander Dyagilev alervdvcw at gmail.com
Wed Jul 10 15:11:53 CEST 2019


In my app I have 2 processes: activity with main UI (1st process) and a 
service (2nd one).

My activity takes (and updates) some data from service and displays it 
in its UI.

Service is not shutting down until activity is connected to it (I use 
QLocalServer in service).

So, the problem is that sometimes Android do not want to shutdown my 
acitity even if it's running for a long time in the background and the 
user is not using it. This leads to service running in the background 
too, and Android constantly warns the user about my app is running in 
the background.

Is there a way to automatically shutdown(kill) the activity if it's not 
active during some reasonable amount of time?

I've tried to use Activity.onPause and set timer, but main thread seems 
to paused and I just can't shutdown my app using the usual means of Qt.

More information about the Interest mailing list