From an Android app I create and run a service that runs in a thread and runs in the background, but completely closing the main app also kills the service.
The thread I create is declared as a Daemon but the service still "kills" me.
My idea is to leave the service running even if we close the main application, a wasap style that when you close the main program the messages continue to arrive.
Any ideas?
If you want to use a service and it continues executing the process even destroying the application , you must define:
You can see as an example this service that plays an audio file:
You can also make use of a BroadcastReceiver
DO NOT use threads
because these die when closing the app.
I recommend you to use a class extended to Service
}
You start the service from the Activity
with:
and to stop it: