Because the Android program has an upgrade push, and put the push prompt window in the Kaiping map that page, and kaiping map page four seconds, and then go to the main interface, no upgrade nothing, but if you click Cancel then the window disappears, do not click the words have been shown, although the program has no bug, But the log output will be error, and the robustness of the program is certainly not, and then would like to use the thread sleep, but not appropriate, Bo Master selected timer, three seconds user does not operate automatically disappear, open screen display is still unaffected, good, on the code:
public class Timertaskclass { timer timer; Long endTime = System.currenttimemillis () +; Public timertaskclass (int seconds) { timer = new timer (); Timer.schedule (New Localtimertask (), 0, seconds *); } Class Localtimertask extends TimerTask { Boolean flag = true; public void Run () {while (flag) { if (system.currenttimemillis () = = EndTime) { L.D ("----------- Now the time-------------", System.currenttimemillis () +" "); Message m = Message.obtain (); M.what = 3; Progresshandler.sendmessage (m); Timer.cancel (); Flag = FALSE;}}}}
This is done by recording the time of the system by calculating the difference to calculate the time, and then sending a message, handing over the task of updating the UI to handler processing.
Simply say the timer in Java, the actual need, no detailed