目前我正在开发一个新的Android应用程序。我需要蓝牙来支持这个应用程序。每次我想通过serversocket/socket系统连接两个(配对的)设备时,我都无法创建一个可用的socket。它总是返回:
所以我的问题是:我使用了无效的UUID吗?如果不是这种情况,你有什么其他建议可能出了问题?
事先感谢您的帮助。
java.io.IOException: read failed, socket might closed or timeout, read ret: -1
所以我的问题是:我使用了无效的UUID吗?如果不是这种情况,你有什么其他建议可能出了问题?
public Accept(BluetoothAdapter bt, BluetoothDevice device, Context context) {
try {
BluetoothAdapter.getDefaultAdapter().cancelDiscovery();
BluetoothServerSocket tmp = null;
try {
UUID uuid = UUID.fromString("00001101-0000-1000-8000-00294F9B3423");
//Here is the point when it doesn't work...
tmp = bt.listenUsingRfcommWithServiceRecord(context.getResources().getString(R.string.bt_string_for_profile_image), uuid);
} catch (Exception e) {
}
mmServerSocket = tmp;
bt_device = device;
} catch (Exception e) {
}
}
事先感谢您的帮助。