main_thread=new Thread(new Runnable() {
public void run() {
while (time > 0&&!cancle) {
System.out.println(time);
try {
Thread.sleep(1000);
mHandler.post(new Runnable() {
public void run() {
String text = getString(R.string.LeftTime);
message.setText(text + time);
}
}
}
});
time--;
if (time <= 0) {
Intent intent = new Intent();
intent.setClass(MapActivity.this,
RateActivity.class);
finish();
startActivity(intent);
}
if(cancle)
{
return; //结束线程
}
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
private void sleep(int i) throws InterruptedException {
Thread.sleep(i);
}
});
main_thread.start();