Hi, I am using bluetooth socket and i have problem when use inputstream for reading bytes... Problem its here: when i call function inputStream.read(buffer, -1, 5); or inputStream.read(buffer);...
myTimerSend = new Timer();
//final byte[] buffer=new byte[20];
//int bytes;
myTimerSend.schedule(new TimerTask() {
public void run() {
runOnUiThread(new Runnable() {
public void run() {
if(connectStat==true){
if(buttonRight.isPressed()==true) SendByte = (byte) 0xFF; else SendByte = (byte) 0x00;
write(SendByte);
final BufferedInputStream bufi = new BufferedInputStream(inputStream);
byte[] buffer = new byte[1024];
try {
btSocket.connect();
inputStream.read(buffer, -1, 5);
bufi.read(buffer);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
});
}
}, 0, 1);
Please help...
myTimerSend = new Timer();
//final byte[] buffer=new byte[20];
//int bytes;
myTimerSend.schedule(new TimerTask() {
public void run() {
runOnUiThread(new Runnable() {
public void run() {
if(connectStat==true){
if(buttonRight.isPressed()==true) SendByte = (byte) 0xFF; else SendByte = (byte) 0x00;
write(SendByte);
final BufferedInputStream bufi = new BufferedInputStream(inputStream);
byte[] buffer = new byte[1024];
try {
btSocket.connect();
inputStream.read(buffer, -1, 5);
bufi.read(buffer);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
});
}
}, 0, 1);
Please help...