How to periodically scan for bluetooth devices on android

后端 未结 4 1267
没有蜡笔的小新
没有蜡笔的小新 2020-12-07 16:35

Hi this may sound as a stupid question.But I was unable to find any answers for this, thus posting here.

I am building an indoor application which continuously scans

4条回答
  •  死守一世寂寞
    2020-12-07 17:31

    Your code snippet should work - Only that it will be expensive in terms of power draw and will certainly kill your device/phone in a few hours. The startDiscovery() does a 2 step process, finding the device by inquiring for it and followed by a name discovery ie paging and connecting to the device,

    Unfortunately Android does not provide any API to control this and do only inquiry , also there is a periodic inquiry feature defined and supported by most Bluetooth chipsets, Android currently does not have any API to do periodic inquiry which could have been more ideal for your use case.

提交回复
热议问题