且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用GattServer以编程方式清除Bluetooth缓存

更新时间:2022-12-30 21:30:54

一种解决方案-使用反射解决此问题.

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());
        }
    }

注意:我不推荐这种方式