Reputation: 2038
I need a suggestion to implement the following situation:
Showing a dialog between two long run operation (SQLite DB and Network operation) that need to be performed not in UI Thread
.
Which dialog is shown depends on the result of first long run operation, whereas which second long run operation is performed depends on the option selected by the user in the dialog. I have used two AsynTask
(like below) to make this but program flow is very messy.
Any suggestions to make this more easily?
Upvotes: 1
Views: 111
Reputation: 3723
You can run each of the tasks in a separate service with its own AsyncTask and have them send their results to a Handler on the UI thread.
The handler should include the logic of deciding what to do with the input.
The communication should go through the bundle via message or a new Parcellable of your creation.
If these operation are long you should consider the user will dismiss the dialog and notify him globally [from Application or notification bar]
Upvotes: 1