android - Create SOS signal using Java.Util.Timer -
i want create android app performs sos signal using flashlight on phone , know how command flash light.
this want flash lite do:
1) flash lite on 1 sec 2) flash lite off 1 sec 3) flash lite on 1 sec 4) flash lite off 1 sec 5) flash lite on 1 sec 6) flash lite off 1 sec 7) flash lite on 3 seconds 8) flash lite off 1 sec 9) flash lite on 3 seconds 10) flash lite off 1 sec 11) flash lite on 3 seconds 12) flash lite off 1 sec 13) flash lite on 1 sec 14) flash lite off 1 sec 15) flash lite on 1 sec 16) flash lite off 1 sec 17) flash lite on 1 sec 18) flash lite off 1 sec
how can accomplish using timer class in java?
the best approach create class definitions of alphabet , equivalent in morse code. numbers can added well. way can come in text, not sos.
if sos goal, creating class might overkill still practice.
have @ docs timer class
http://docs.oracle.com/javase/7/docs/api/java/util/timer.html << updated link
this method used timer class in illustration below. sos quite possible add together forloop run sequence many seconds, , command led light.
public void schedule(timertask task, long delay, long period)
//usage of timer
import java.util.*;
public class timerdemo {
public static void main(string[] args) { // declare , create task timertask tasknew = new timertask() { // runs our task @override public void run() { system.out.println("timer running..."); } }; // declare , create timer timer mytimer = new timer(); /* schedule timer (task scheduled, delay in ms before task * execution, period in ms between successive tasks executions */ mytimer.schedule(tasknew, 500, 1000); }
}
i hope gives improve example.
java android timer led
No comments:
Post a Comment