80,351
社区成员
发帖
与我相关
我的任务
分享
private class GetDataThread extends Thread {
private final BluetoothSocket iSocket;
private InputStream mmInStream;
public GetDataThread(BluetoothSocket socket) {
iSocket = socket;
}
public void run() {
try {
mmInStream = iSocket.getInputStream();
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
return;
}
if(!mBTConnect)
return;
{
try {
byte[] data = {1,2,3,4,5,6}
mmOutStream.write(data);
} catch (IOException e) {
Log.e("print", "Exception during write", e);
}
}
Log.e(TAG, "BEGIN mConnectedThread");
int Err = ConstDefine.enumNetPromptMsg.ErrOK;
final int len = 9;
byte b[] = new byte[len];
Calendar now = Calendar.getInstance();
mBeginMillsecond = now.getTimeInMillis();
while (readflag) {
if(!mBTConnect)
{
return;
}
try {
if(mmInStream.read(b) != -1){
}
}catch (IOException e) {
Log.e(TAG, "disconnected", e);
cancel();
break;
}
}
}
public void cancel() {
try {
if(mmOutStream != null){mmOutStream.close();}
if(mmInStream != null){mmInStream.close();}
// if(mmSocket != null){mmSocket.close();}
} catch (IOException e) {
//Log.e(TAG, "close() of connect socket failed", e);
}
}
}