java.lang.RuntimeException Can't create handler inside thread that has not called Looper.prepare();


java.lang.RuntimeException: Can’t create handler inside thread that has not called Looper.prepare();

不要从UI线程外部访问Android UI

1
Activity.runOnUiThread(Runnable)
1
2
3
4
5
6
7
8
9
10
11
12
13
new Thread()
{
public void run()
{
Activity.runOnUiThread(new runnable()
{
public void run()
{
//Do your UI operations like dialog opening or Toast here
}
});
}
}.start();