• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Bluetooth inputStream Receive problem

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...
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones