I would like to send a byte via bluetooth but can not figure out how to change my java code. My code sends a string and not a byte, but if I try to change it gives me error the Activity Main. This is the code:
public void write(String income) {
try {
mmOutStream.write(income.getBytes());
for(int i=0;i<income.getBytes().length;i++)
Log.v("outStream"+Integer.toString(i),Character.toString((char)(Integer.parseInt(Byte.toString(income.getBytes()[i])))));
try {
Thread.sleep(20);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} catch (IOException e) { }
}
I tried to change so
public void write(byte[] bytes) {
try {
mmOutStream.write(bytes);
} catch (IOException e) { }
}
but in the MainActivity get this error:
The method write(byte[]) is undefined for the type Bluetooth
and this is the comand
Bluetooth.write(new byte[]{(byte) prova});
can anyone help me? Thanks.
0 comments:
Post a Comment