android bluetooth can't connect

夙愿已清 提交于 2019-12-02 16:25:03

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

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).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!