public sendReceive (BluetoothSocket socket){
bluetoothSocket=socket;
InputStream tempIn =null;
OutputStream tempOut=null;
try {
tempIn=bluetoothSocket.getInputStream();
tempOut=bluetoothSocket.getOutputStream();
} catch (IOException e) {
e.printStackTrace();
}
}
错误:方法声明无效;需要返回类型
以及sendReceive的所有功能。
private class SendReceive extends Thread{
private final BluetoothSocket bluetoothSocket;
private final InputStream inputStream;
private final OutputStream outputStream;
public sendReceive (BluetoothSocket socket){
bluetoothSocket=socket;
InputStream tempIn =null;
OutputStream tempOut=null;
try {
tempIn=bluetoothSocket.getInputStream();
tempOut=bluetoothSocket.getOutputStream();
} catch (IOException e) {
e.printStackTrace();
}
}
public void run(){
byte[] buffer=new byte[1024];
int bytes;
while(true){
try {
bytes=inputStream.read(buffer);
handler.obtainMessage(STATE_MESSAGE_RECEIVER,bytes,-1,buffer).sendToTarget();
} catch (IOException e) {
e.printStackTrace();
}
}
}
public void write(byte[] bytes){
try {
outputStream.write(bytes);
} catch (IOException e) {
e.printStackTrace();
}
}