I have an issue.
1. I have two threads: ‘worker’ and ‘UI’ thread.
2. Worker keeps on waiting for data from server, when gets it notifies to UI thread.
3. On update UI shows Toast message on screen.
Step 3 is problem as it says:
android.view.ViewRoot$CalledFromWrongThreadException: Only the
original thread that created a view hierarchy can touch its views.
Using mHandler, runOnUIThread slows down the UI thread (UI displays webview), as I have to continuously check for data from server.
Use AsyncTask to implement this. Override doInBackground to get the data (it is executed on the separate thread), then override onPostExecute() to show the toast (it is executed on the UI thread).
Here is good example http://www.screaming-penguin.com/node/7746
And here is official docs.
UPD: Example on how to handle partial progress.