通过蓝牙将 Android 设备传输至诺基亚
我正在尝试将我的 Android 手机连接到我的诺基亚手机。我可以通过我的 Andorid 应用程序发现诺基亚手机。我可以成功创建套接字:
btSocket = device.createRfcommSocketToServiceRecord(MY_UUID);
但是当我尝试连接到诺基亚手机时,连接出现错误。 我正在尝试运行以下链接中提供的示例:
代码出现错误onResume()
方法中存在的 btSocket.connect()
被执行:
Logcat:
D/BluetoothAdapter( 176): checkBluetoothAddress
E/THINBTCLIENT( 4738): ON RESUME: Exception during connect.
E/THINBTCLIENT( 4738): java.io.IOException: Service discovery failed
E/THINBTCLIENT( 4738): at android.bluetooth.BluetoothSocket$SdpHelper.doSdp(BluetoothSocket.java:377)
E/THINBTCLIENT( 4738): at android.bluetooth.BluetoothSocket.connect(BluetoothSocket.java:201)<br>
E/THINBTCLIENT( 4738): at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1149)
这是我的 UUID
使用:
private static final UUID MY_UUID = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB");`
请让我知道我哪里出错了。我尝试在 Stackoverflow 和互联网上寻求帮助,但没有找到任何帮助。
I am trying to connect my Android phone to my Nokia phone. I can discover the Nokia phone through my Andorid application. I can create the socket successfully:
btSocket = device.createRfcommSocketToServiceRecord(MY_UUID);
But when I try to connect to the nokia phone there is an error in connection.
I am trying to run this sample provided in the link below:
And an error is occured when the code btSocket.connect()
which is present in the onResume()
method is executed:
Logcat:
D/BluetoothAdapter( 176): checkBluetoothAddress
E/THINBTCLIENT( 4738): ON RESUME: Exception during connect.
E/THINBTCLIENT( 4738): java.io.IOException: Service discovery failed
E/THINBTCLIENT( 4738): at android.bluetooth.BluetoothSocket$SdpHelper.doSdp(BluetoothSocket.java:377)
E/THINBTCLIENT( 4738): at android.bluetooth.BluetoothSocket.connect(BluetoothSocket.java:201)<br>
E/THINBTCLIENT( 4738): at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1149)
And this is the UUID
I am using:
private static final UUID MY_UUID = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB");`
Kindly let me know where I am going wrong. I tried to look for help in Stackoverflow and on the internet in general, but no help was found.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我使用了这里找到的解决方案:在Android上使用蓝牙服务发现失败异常< /a>
由于某种我不清楚的原因,反射在某些普通方法不起作用的设备上起作用。试试这个:
I used the solution found here: Service discovery failed exception using Bluetooth on Android
For some reason unclear to me, reflection works on some devices where the ordinary method doesn't work. Try this: