2017-08-04 136 views
-3

当我只发送一个字母或一个数字时,我的代码工作正常,但现在我试着编辑它使它发送两个值和一个“:”,但由于某种原因它不起作用。以下是我正在使用的代码:需要通过蓝牙发送一个字符串

@Override 
    public void onMove(int angle, int strength) { 
    mTextViewAngleLeft.setText(angle + "°"); 
    mTextViewStrengthLeft.setText(strength + "%"); 
    command = (angle + ":" + strength + "\n"); 
    try { 
     outputStream.write(command.getBytes()); //transmits the value of command to the bluetooth module 
    } catch (IOException e) { 
     e.printStackTrace(); 
    } 
    } 

命令声明为String

+0

试试这个代码https://stackoverflow.com/questions/22899475/android-sample-bluetooth-code-to-send- a-simple-string-via-bluetooth –

+0

https://stackoverflow.com/a/22899728/3983054 –

+0

1)为你的问题添加一些标点符号。 2)'它不工作'它究竟不工作? –

回答

0

转出它是一个硬件错误(蓝牙是不能正常工作)