用JAVA 的方法:
用线程睡常见的方式:
class timeextends TimerTask implements Runnable{
public void run() {
System.out.println("开始倒计时2秒");
Looper.prepare();
//计数器加1
Repeat_num++;
//将字节输入管道并发送
try {
timer = new Timer();
timer.schedule(new callback(), 2000);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Looper.loop();
}
class callback extends TimerTask {
public void run() {
Looper.prepare();
System.out.println("计时结束");
//参数加1,表示是重发信息,在界面上不要再出现弹出式的提醒,搞成后台静默式发送
try {
clickOnAndroid_saveSendTo(1);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Looper.loop();
}
}
}
用线程睡常见的方式:
public class Calculation {
public static void calculate(int sleepSeconds){
try {
Thread.sleep(sleepSeconds * 1000);
} catch (Exception e) {
// TODO: handle exception
}
}