什么是您的设备的getBTMajorDeviceClass? 如果BluetoothClass.Device.Major.UNCATEGORIZED,尝试生成自己的UUID:
private UUID generateUuid() {
String android_id = Secure.getString(getApplicationContext()
.getContentResolver(), Secure.ANDROID_ID);
Log.i("System out", "android_id : " + android_id);
final TelephonyManager tm = (TelephonyManager) getBaseContext()
.getSystemService(Context.TELEPHONY_SERVICE);
final String tmDevice, tmSerial, androidId;
tmDevice = "" + tm.getDeviceId();
Log.i("System out", "tmDevice : " + tmDevice);
tmSerial = "" + tm.getSimSerialNumber();
Log.i("System out", "tmSerial : " + tmSerial);
androidId = ""
+ android.provider.Settings.Secure.getString(
getContentResolver(),
android.provider.Settings.Secure.ANDROID_ID);
UUID deviceUuid = new UUID(androidId.hashCode(),
((long) tmDevice.hashCode() << 32) | tmSerial.hashCode());
return deviceUuid;
}
,并用它在套接字创建createRfcommSocketToServiceRecord(generateUuid());
*需要READ_PHONE_STATE
你检查了Android样品蓝牙聊天应用?它通过蓝牙提供完全功能的聊天,我试过了,它没有问题。试一试。 – k0sh 2013-03-12 13:52:19
我希望我能投票下来...呵呵,只是开玩笑。但是,当然,我做到了。我花了数小时参考实施。我花了更多的时间用AIDL黑客来反映隐藏的蓝牙类,以建立一个程序化连接。我花了很多时间检查谷歌链接和实施dozends。我花了几个小时阅读了维基上的蓝牙规范以及几乎所有我可以在此找到的内容...... – 2013-03-12 14:09:15
@JohnSmith不幸的是,没有办法降低评论...回到你的问题当你尝试使用哪种方法时检索套接字? – Rigotti 2013-03-12 18:16:04