I am starting android service by startService() in Activity A. I have multiple activities in my application. Here the problem is with onDestroy() of Activities.
What I am doing is generating an event in onDestroy() of activity. Application class is a subscriber of this event and I stopping this service in Application class. I know onDestroy() is not guaranteed to be called every time when the application is closing.
I also need to keep service running till application is running. And what is the best way to stopping service on the closing of application?
I am using otto library for event bus.