Android 到诺基亚数据传输通过蓝牙

标签 android bluetooth nokia

我正在尝试将我的 Android 手机连接到我的诺基亚手机。我可以通过我的 Andorid 应用程序发现诺基亚手机。我可以成功创建套接字:

btSocket = device.createRfcommSocketToServiceRecord(MY_UUID);

但是当我尝试连接到诺基亚手机时出现连接错误。 我正在尝试运行以下链接中提供的示例:

http://www.anddev.org/code-snippets-for-android-f33/serial-over-bluetooth-simple-test-client-t11106.html

onResume() 方法中的代码 btSocket.connect() 被执行时发生错误:

日志:

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 和互联网上寻求帮助,但没有找到任何帮助。

最佳答案

我使用了在这里找到的解决方案:Service discovery failed exception using Bluetooth on Android

出于某种我不清楚的原因,反射在某些普通方法不起作用的设备上有效。试试这个:

Method m = device.getClass().getMethod("createRfcommSocket", new Class[] {int.class} );
btSocket = (BluetoothSocket) m.invoke(device, 1);      

关于Android 到诺基亚数据传输通过蓝牙,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8239997/

相关文章:

android - 首次从 Android 市场安装 Android 应用程序时出现问题

Android - 下一步按钮不起作用

android - 如何在android中读取新消息的消息内容?

java - 打开失败 EACCES(权限被拒绝)

java - Listview 和 OnItemClickListener(蓝牙设备)

java - 为什么 Bluecove 需要安装 libbluetooth-dev 软件包才能运行

c++ - 对 `RPositionServer::RPositionServer()` 的 undefined reference

java - 最佳实践——Java串口蓝牙连接 HC-05

c++ - undefined reference

java-me - J2ME 媒体播放器可以在诺基亚 E65 上运行吗?