please hold back on the downvotes for a second and read.
After my question Is there a way to create a controlling instance that controls several activities of my app?
and after reading detect when application is closed
i am wondering... i have lots of activities in my app, and several services, i access about all the hardware that the device has. Access to those things makes sense for as long as the app is running. Activities can change but the need for access to those things is there in every single one of them (slight exaggeration).
I know of two ways that seem suitable for my needs.
1) i extend Application and instantiate some objects there that access or calculate stuff that is needed everywhere
2) i do the same in a subclass of Activity
In both cases i would like to unregister broadcastreceivers and stop services. Services are not bound (for a reason). So whats the proper way to close and unregister things in all those cases that can happen ?
its possible that onDestroy is not called
i am not notified of my process being closed/killed by the system
So how do i create something that is always there for all my activities but stops and cleans up whenever my app is being closed ?!