How to Programmatically Clear Bluetooth Cache using GattServer

前端 未结 1 1849
难免孤独
难免孤独 2021-02-05 06:36

I\'m slightly familiar with BLE and I am facing some problem with an inherited code. So the app works like that:

  1. With BLE enabled the app scans for devices
1条回答
  •  夕颜
    夕颜 (楼主)
    2021-02-05 07:18

    One solution - solve this issue using reflection.

    private void refreshDeviceCache(BluetoothGatt gatt) {
            try {
                Method localMethod = gatt.getClass().getMethod("refresh");
                if(localMethod != null) {
                    localMethod.invoke(gatt);
                }
            } catch(Exception localException) {
                Log.d("Exception", localException.toString());
            }
        }
    

    Note : I am not recommended this way

    0 讨论(0)
提交回复
热议问题