I want to implement a service which will launch an AsyncTask.
In the AsyncTask onProgressUpdate() I want to update a TableLayout in the main thread.
All is fine, but for one doubt: How do I handle the situation where the main thread has been destroyed or is not visible?
The service will continue until it stopSelf() and this is what I want.
But how does the AsyncTask know not to update the TableLayout?
I think the solution is along the lines of lettting the service know when the main Activity is visible or not through messages on onResume() and onPause().
The service in turn will set a flag in the AsyncTak, when the flag is false the onProgressUpdate() will exit without doing the UI update.
So I guess, if I understood the Services documentation right, my Service will have to be started-sticky and also bound by the same activity. I only need to figure out how to re-bind the running service.