Android Bluetooth - Can't connect out

后端 未结 2 1624
长发绾君心
长发绾君心 2020-12-28 23:48

I am developing an application which uses Bluetooth to connect to a device and send/receive data. I am doing all of my testing with a Nexus One phone.

I have never b

2条回答
  •  悲哀的现实
    2020-12-29 00:26

    I would ignore the stopDiscovery error - its good that you're cancelling discovery before making your connection. Per the SDK docs:

    Because discovery is a heavyweight precedure for the Bluetooth adapter, this method should always be called before attempting to connect to a remote device with connect(). Discovery is not managed by the Activity, but is run as a system service, so an application should always call cancel discovery even if it did not directly request a discovery, just to be sure.

    So with that said, were you able to get the Bluetooth Chat example to work before you made any modifications to the code?

    The UUID you want for SPP/RFCOMM is:

    static UUID UUID_RFCOMM_GENERIC = new UUID(0x0000110100001000L,0x800000805F9B34FBL);
    

    or defined another way (both accomplish the same thing).

    static final UUID UUID_RFCOMM_GENERIC = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB");
    

提交回复
热议问题