public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.welcome);
// jumToOtherAct();
new Thread(){
public void run()
{
try {
sleep(5000);
jumToOtherAct();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}.start();
jumToOtherAct()方法就是做一个判断是否又网络,如果没有网络就弹出一个dialog提示检查网络,但是程序报错, java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
该怎么解决呢?
super.onCreate(savedInstanceState);
setContentView(R.layout.welcome);
// jumToOtherAct();
new Thread(){
public void run()
{
try {
sleep(5000);
jumToOtherAct();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}.start();
jumToOtherAct()方法就是做一个判断是否又网络,如果没有网络就弹出一个dialog提示检查网络,但是程序报错, java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
该怎么解决呢?
public void run() {
Looper.prepare();
MyHandler handler = new MyHandler();
Looper.loop();
}