蓝牙socket通信 收不到数据 各位大侠看看这报的错是啥意思……
解决方案 »
- 【求助】更改系统设置选项,控制APK的溢出菜单按钮
- Android 象棋电脑智能实现
- 动态布局位置无效 求高手
- 程序中过多使用Timer和TimerTask的影响
- 在线等!!高手!!!急,android有解析vcard的api没?
- android tab布局问题
- 20分在线等:在android中发送一个Notifiitycation,如何只显示在最上方的标题栏,却不显示在通知栏(标题栏下拉时)
- 2013-7月后下载安卓SDK是要求Android Support Library, revision 18,有人有吗?官网无法下载。
- Android模拟PC发送请求(不被服务器识别到)
- IDEA14 创建布局空指针,布局文件打不开?
- 新手,AVD窗口无法关闭,不知怎么办
- AVD 无法关闭
at android.bluetooth.bluetoothsocket.readnative(Ntive Method)
at android.bluetooth.bluetoothsocket.read(bluetoothsocket. java:307)
at android.bluetooth.bluetoothInputStream.read(bluetoothInputStream. java:96)
at java.io.inputStream.read(InputStream. java:157)
at com.card.mango.receivecard$AceptThread.run(receivecard java:103)
No keyboard for id 65536
using default keymap :system/user/keychars/qwerty.kcm,bin终于输完了 看在我这么辛苦的份上 大家帮我看看吧……
源代码如下private class AcceptThread extends Thread {
private final BluetoothServerSocket mmServerSocket;
private InputStream mmInStream;
public AcceptThread() {
// Use a temporary object that is later assigned to mmServerSocket,
// because mmServerSocket is final
final String SPP_UUID = "00001101-0000-1000-8000-00805F9B34FB";
UUID uuid = UUID.fromString(SPP_UUID);
BluetoothServerSocket tmp = null;
try {
// MY_UUID is the app's UUID string, also used by the client code
tmp = mBluetoothAdapter.listenUsingRfcommWithServiceRecord(Name,uuid);
} catch (IOException e) { }
mmServerSocket = tmp;
}
public void run() {
BluetoothSocket socket = null;
// Keep listening until exception occurs or a socket is returned
while (true) {
try {
socket = mmServerSocket.accept();
} catch (IOException e) {
break;
}
// If a connection was accepted
if (socket != null) {
try {
System.out.println("接收到socket:"+socket);
//manage the connection , begin to exchange stream
mmInStream = socket.getInputStream();
System.out.println("接收到stream:"+mmInStream);
byte[] buffer = new byte[1024];
int temp = 0;
while((temp = mmInStream.read(buffer)) != -1) {
System.out.println(new String(buffer,0,temp));
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
finally{
cancel();
}
}
}
}
/** Will cancel the listening socket, and cause the thread to finish */
public void cancel() {
try {
mmServerSocket.close();
} catch (IOException e) { }
}
}
System.out.println("接收到socket:"+socket);
System.out.println("接收到stream:"+mmInStream);
这两行,
打印出的信息:接收到的socket:android.bluetooth.bluetoothsocket@4054a298
接收到的stream:android.bluetooth.bluetoothInputStream@4054b818我想问的是
@4054a298
@4054b818
都是什么意思啊………………看不懂……