continuous sending of data

609 views Asked by At

The android application is bulit in such a way that when data is being sent(on clicking the button) to the usb device ,LED toggles and the data is being displayed. I want data to be sent continuously without any manual intervention. Kindly help

   if (mInputStream != null)
       {
          int Data = 0;
           try {
             Data = mInputStream.read();
           } catch (IOException e) {
           }
            if (Data == LED_ON)
            {

            ledStatus.setText("LED is ON");             
            }
             else if (Data == LED_OFF)
            {

            ledStatus.setText("LED is OFF");                                
            }
        else
        {
            ledStatus.setText("Request failed");                
        }

            }
           else 
            {
        ledStatus.setText("mInputStream == null");

            }
1

There are 1 answers

5
jeet.chanchawat On BEST ANSWER

this time I have tested it myself... it should definitely work paste it in your onCreate() good luck :)

 Timer t = new Timer();
        t.schedule(new TimerTask(){
              public void run(){
                           // write the method name here. which you want to call continuously
                  Log.d("timer", "timer");
                  }
                  },10, 1000);