I want to start a service when the users open my application, some of my activities need to bind the service, and when the users close my application, I stop the service.
The question is where can I stop the service. I want my service work when my app is open.
I start the service in Application.onCreate()
method, and I found there is no onDestroy()
method in Application
.
And I tried stop it in the launcher activity onDestroy
, but I don't think this is a good way because the system will recovery launcher activity when low memory.