CountDownTimer
new CountDownTimer(3000, 1000) {
public void onTick(long millisUntilFinished) {
if (mTicketSuccessBtn != null) {
mTicketSuccessBtn.setBackgroundColor(Color.parseColor("#8f8f8f"));
mTicketSuccessBtn.setText("手动出票(" + millisUntilFinished / 1000 + ")");
}
}
public void onFinish() {
if (mTicketSuccessBtn != null) {
mTicketSuccessBtn.setBackgroundColor(Color.parseColor("#3faff8"));
mTicketSuccessBtn.setEnabled(true);
}
}
}.start();
AlarmManager,Handler, Timer, Thread。
AlarmManager
AlarmManager是系统开放的闹钟功能,使用方式和普通的manager没有区别。
AlarmManager am = (AlarmManager)mContext.getSystemService(Context.ALARM_SERVICE); // Schedule the alarm! Intent intent = new Intent(XXXXX);