2012-06-07 67 views
1

android應用程序是這樣的一種方式,當數據被髮送(單擊按鈕)到USB設備時,LED切換並顯示數據。我希望數據在沒有任何手動干預的情況下連續發送。好心幫連續發送數據

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"); 

      } 
+0

你的問題是完全..refresh不清楚它 –

+0

什麼是特定的例外行爲?什麼是詳細的CURRENT行爲? –

+0

我想要的數據USB接收應連續發送到屏幕 – user1437027

回答

0

這時候我已經測試它自己... 它絕對應該工作 其粘貼到您的onCreate()好運:)

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); 
+0

http://developer.android.com/resources/articles/timed-ui-updates.html –

+0

當m點擊按鈕然後LED切換n數據交換需要地點。我希望進行數據交換時不需要觸摸按鈕 – user1437027

+0

chk編輯後的代碼 –