定时器+hander:
public Timer startTimer() { //定时器
TimerTask mTimerTask = new TimerTask() {
@Override
public void run() {
Message message = new Message();
message.what = 1;
handler.sendMessage(message);
}
};
Timer timer = new Timer(); //定时器
timer.schedule(mTimerTask, 1000, 2000);
// timer.cancel();
return timer;
}
Handler handler = new Handler() {
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
switch (msg.what) {
case 2:
getInfo();
break;
case 1:
qxSDK.getStartConfigs(); //获取千寻到期时间
break;
case 3:
//什么都不干
break;
}
}
};