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

            }
4

1 回答 1

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);
于 2012-06-07T13:51:46.550 回答