I'm developing a software that has kind of 3 parts.
A broadcastlistener that will react when phone has completed booting.
A service that handles my database stuff and searches into the db.
A gui componen for user to use the software.
My problem is that when GUI is shutdown (and service is unbound) the service is destroyed also. I was wondering how I could make the service to run as a Daemon so that would not get destroyed ever.
So to be clear. At first the service is running, even tho the GUI is not. When the GUI connects (bind) to the service (localservice) it works. After I shutdown the GUI, my service will run to method onDestroy().
I need to keep the service alive, because it is supposed to react to incoming calls and act on them. Starting the service on incoming call might be too slow.
By broadcast listener starts the service as follows:
Api doc says that the service should stay running until stopService() is called. But when my GUI disconnects it still gets nuked.
"Using startService() overrides the default service lifetime that is managed by bindService(Intent, ServiceConnection, int): it requires the service to remain running until stopService(Intent) is called, regardless of whether any clients are connected to it. "
** edit **
nwm. I found out why this happened. Service had crashed during testing, and my GUI started it again by binding, so of course it died on unbind. Rebootting fixed this as my listner started service after boot with startService(..);