参考资料:http://jeff-pluto-1874.iteye.com/blog/869710,
http://www.cnblogs.com/Greenwood/archive/2011/02/27/1966472.html。
关键代码
Timer timer=new Timer();
timer.schedule(new TimerTask() {
@Override
public void run() {
Looper.prepare();
// TODO Auto-generated method stub
Toast.makeText(getApplicationContext(), "您的账户已经刷新.", Toast.LENGTH_SHORT).show();
Looper.loop(); //codes after this will not be excuted.
}
}, 5000);
Looper.prepare()和 Looper.loop()的位置很重要。Looper.loop()后的代码是不会被执行的来。