To put it simply, there is no detailed explanation of the timer in java.
Because the Android program has an upgrade push, and the push Prompt window is placed on the page of the Open Graph, and the Open Graph page is four seconds, then the main interface is displayed, no upgrade is required, however, if you click Cancel, the window will disappear. If you do not click it, it will always be displayed. Although the program has no bugs, the log output will report an error, and the robustness of the program will certainly not work, the timer selected by the blogger disappears automatically when the user does not perform the operation for three seconds, and the screen opening display is still unaffected. Okay, go to the Code:
Public class TimerTaskClass {Timer timer; long endTime = System. currentTimeMillis () + 3000; public TimerTaskClass (int seconds) {timer = new Timer (); timer. schedule (new LocalTimerTask (), 0, seconds * 1000);} class LocalTimerTask extends TimerTask {boolean flag = true; public void run () {while (flag) {if (System. currentTimeMillis () = endTime) {L. d ("----------- current time -------------", System. currentTimeMillis () + ""); Message m = Message. obtain (); m. what = 3; progressHandler. sendMessage (m); timer. cancel (); flag = false ;}}}}}
Here, the system time is recorded and the difference is calculated to calculate the time, and then a message is sent to send the ui update task to handler for processing.