0

In my app I am using beacons name for work. After name change of beacons, some are seeing OK, some not. They show old name. I find that there's problem with bluetooth cache in device. How can I clear cache? I tried:

public void btDevice(){
    BluetoothDevice device = mbluetoothAdapter.getRemoteDevice(idKey);
    device.fetchUuidsWithSdp(); 

But not success. I wish to avoid use android.bluetooth because I wish to avoid prompting for pairing every time device is in range. Now I use altbeacon lib to manage beacons.

Larme
  • 24,190
  • 6
  • 51
  • 81
kolo
  • 85
  • 1
  • 1
  • 9

1 Answers1

0

On Android, the bluetooth name is parsed from the scan response by the operating system. You have very little control over how this works -- the last Bluetooth LE scan response detected for a device is associated with Android's object for a device with the same mac address. If the device name changes at a later time, Android will continue reporting the old name unless a new scan response is received by the OS. It is the OS that decides when to request a new scan response, not the application code.

As you have seen, none of this is under your control and it is not guaranteed. I don't know of any workarounds on this, and avoid using scan responses for data (like the bluetooth name) that may change over time.

davidgyoung
  • 63,876
  • 14
  • 121
  • 204
  • I need bt name it's easier and more flexible(in my app) than using minor/major numbers. Beacon name is address html element. I clean bluetooth data in Settings/applications but this doesn't help. This problem is pain in the ... only for me, because i setup my beacons with the same device and when i testing my app i see old names and app crashes. User will connect first time and get proper name. But now i have problem with building my app. – kolo Sep 09 '15 at 13:33