I'm developing an Android app. At the start this app show to the user a list of bluetooth devices and when he chooses one of they opens an other activity.
My goal is : after some day when the user will reopen the app the app will have to remember the ble device and it have to try to reconnect to it.
For now I have obtained my goal in this way :
- I memorize in preference the mac address of the chosen device
- When the user reopen the app the app do a hidden scan and try to reconnect to a device with a same MAC address.
- for retrieve the mac address I use the function getAddress() (when I try to connect to the android peripheral this function gives me some problem, because the the device changes his MAC address at each starts :/)
There is a best way to obtain the same thing ?
Off topic : The function onScanResult in the ScanResult some time return to me null device, is it normal ? I have uses startLeScan(UUID[] serviceUuids, BluetoothAdapter.LeScanCallback callback) and after lollipop I use the new version of the startLeScan with Scanfilter. Can it be the problem ?