My program does some network activity in a background thread. Before starting, it pops up a progress dialog. The dialog is dismissed on the handler. This all works fine, exc
If you create a background Service that does all the heavy lifting (tcp requests/response, unmarshalling), the View
and Activity
can be destroyed and re-created without leaking window or losing data. This allows the Android recommended behavior, which is to destroy an Activity on each configuration change (eg. for each orientation change).
It is a bit more complex, but it is the best way for invoking server request, data pre/post-processing, etc.
You may even use your Service
to queue each request to a server, so it makes it easy and efficient to handle those things.
The dev guide has a full chapter on Services.