2014-08-11
今天Nexus到了,终于可以开始搞Android BLE开发了,好激动,今晚先看看官方API吧。API地址:http://developer.android.com/guide/topics/connectivity/bluetooth-le.html
2014-8-13
修改了一个网上找的DEMO,可以使手机搜索到iBeacon基站,实时显示信号强度。但是我使用的是递归调用循环搜索,有个很大的问题是搜索功耗很高。Google是这么说的
To find BLE devices, you use the startLeScan()
method. This method takes aBluetoothAdapter.LeScanCallback
as a parameter. You must implement this callback, because that is how scan results are returned. Because scanning is battery-intensive, you should observe the following guidelines:
- As soon as you find the desired device, stop scanning.
- Never scan on a loop, and set a time limit on your scan. A device that was previously available may have moved out of range, and continuing to scan drains the battery.