Bluetooth search device implementation

Get Bluetoothhadapte ba first
Turn on Bluetooth
ba.enable()
Start search< a i=4> ba.startdiscovery() Note that this is just an action and will not return results The search results need to be broadcast to obtain< a i=7> Register and receive broadcast Bluetoothdevice.action_found Get the information of the searched device from the intent If you want to calculate the number of searched devices and then listen to the broadcast Bluetoothadapter.action_discovery_finished You can set a global variable count++ when receiving the action_found broadcast At this time get (count), the value of this count is the number of devices searched this time Turn off Bluetooth< /span> ba.disable()












Guess you like

Origin blog.csdn.net/hhhyyyjjj/article/details/109693674