android bluetooth can't connect

后端 未结 2 815
执念已碎
执念已碎 2021-01-31 00:52

I\'ve been having this problem for a while and haven\'t been able to figure it out.

I have a android application that puts all paired devices in a listview. When you cl

相关标签:
2条回答
  • 2021-01-31 01:08

    I got the same error message after connecting the socket a second time. I simply checked if the socket is already connected.

    if(!mmSocket.isConnected())
                mmSocket.connect();
    

    I was testing on Android 4.4.2 (Moto G).

    0 讨论(0)
  • 2021-01-31 01:17

    The jelly bean bluetooth stack is markedly different from the other versions.

    This might help: http://wiresareobsolete.com/wordpress/2010/11/android-bluetooth-rfcomm/

    In gist: The UUID is a value that must point to a published service on your embedded device, it is not just randomly generated. The RFCOMM SPP connection you want to access has a specific UUID that it publishes to identify that service, and when you create a socket it must match the same UUID.

    If you are targeting 4.0.3 device and above , use fetchUuidsWithSdp() and getUuids() to find all the published services and their associated UUID values. For backward compatibility read the article

    0 讨论(0)
提交回复
热议问题