Reputation: 1579
I have a task that runs in the background. I want this background task to use Webview. The background task creates a new activity, Web, via new Intent. All of the webview activities (such as load url, go back, etc) are in methods in Web. Those methods are called from methods in the background tasks. This procedure works fine in some devices.
I am now seeing crashes from some devices with the message:
"android.view.ViewRoot$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views."
after the background calls the goback() method in Web.
Apparently Web is running in a different thread than the background task. What can I do about this?
Upvotes: 0
Views: 1939
Reputation: 1266
Well, you gotta use runOnUIThread ( http://developer.android.com/reference/android/app/Activity.html#runOnUiThread(java.lang.Runnable) ) whenever you update UI from any background task.
Upvotes: 1