06-28 12:07:10.881: E/(930): {total=21 secs, date2=28-06-2012, time2=9:43:09 AM, time1=9:42:48 AM, date1=28-06-2012}
06-28 12:07:11.131: E/testing(930): exception:android.view.ViewRoot$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.
06-28 12:07:11.160: E/(930): {total=24 secs, date2=28-06-2012, time2=10:45:02 AM, time1=10:44:38 AM, date1=28-06-2012}
06-28 12:07:11.601: E/testing(930): exception:java.lang.IllegalArgumentException: The observer is null.
Asked
Active
Viewed 122 times
1
-
you are trying to update the UI element from non UI thread... – Dheeresh Singh Jun 28 '12 at 06:40
-
make sure you are not calling it from a new Thread or AsyncTask.. see this http://stackoverflow.com/questions/5185015/updating-android-ui-using-threads – ngesh Jun 28 '12 at 06:41
4 Answers
2
- .ViewRoot$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views
looks you are trying to update the UI element from non UI thread.
should use Handler
or runOuUIThread
function of activities or Asynctask
as per your need

Dheeresh Singh
- 15,643
- 3
- 38
- 36
-
sure http://www.aviyehuda.com/2010/12/android-multithreading-in-a-ui-environment/ – Dheeresh Singh Jun 28 '12 at 08:35
1
Look at code that is written in a seprate thread and is trying to update your application UI.
You need to put that code in run method of runOnUiThread
.
runOnUiThread(new Runnable() {
public void run() {
// COde to update UI.
}
});

Aqif Hamid
- 3,511
- 4
- 25
- 38
0
You are attempting to modify UI components on a thread that is not the UI thread. Take a look at runOnUiThread
for updating UI components from non-UI threads.

cklab
- 3,761
- 20
- 29
0
You can use threads but all the views, and all the views related APIs, must be invoked from the main thread (also called UI thread.) To do this from a background thread, you need to use a Handler. A Handler is an object that will post messages back to the UI thread for you.

K_Anas
- 31,226
- 9
- 68
- 81