小编use*_*929的帖子

如何找到CLIENT_CHARACTERISTIC_CONFIG?

我需要CLIENT_CHARACTERISTIC_CONFIGUUID 来激活我的应用程序中的通知。在谷歌示例应用程序中,它们是预定义的:

public static String HEART_RATE_MEASUREMENT = "00002a37-0000-1000-8000-00805f9b34fb";
public static String CLIENT_CHARACTERISTIC_CONFIG = "00002902-0000-1000-8000-00805f9b34fb";
Run Code Online (Sandbox Code Playgroud)

我所拥有的只是:

  • 双向服务:b9e875c0-1cfa-11e6-b797-0002a5d5c51b
  • 接收:0c68d100-266f-11e6-b388-0002a5d5c51b
  • 发送:1ed9e2c0-266f-11e6-850b-0002a5d5c51b

如何获取 UUID:

mBluetoothGatt.setCharacteristicNotification(characteristic, enabled);
BluetoothGattDescriptor descriptor = characteristic.getDescriptor(UUID.fromString(needed UUID here));
descriptor.setValue(enabled?BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE : new byte[]{0x00, 0x00});
mBluetoothGatt.writeDescriptor(descriptor);
Run Code Online (Sandbox Code Playgroud)

java uuid android bluetooth-lowenergy sensors

2
推荐指数
1
解决办法
4861
查看次数

使用GUI(Java)启动一个线程

每当调用线程中的run方法时,我的GUI都会冻结,有人知道为什么吗?

主要:

try {
        // Set System Look and Feel
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (UnsupportedLookAndFeelException e) {
        // handle exception
    } catch (ClassNotFoundException e) {
        // handle exception
    } catch (InstantiationException e) {
        // handle exception
    } catch (IllegalAccessException e) {
        // handle exception
    }
    EventQueue.invokeLater(new Runnable() {
        public void run() {
            try {
                MainFrame frame = new MainFrame(null, null);
                frame.setVisible(true);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });
Run Code Online (Sandbox Code Playgroud)

从线程运行方法:

public void run() {
    while (true) {
        System.out.println("test");
    }
} …
Run Code Online (Sandbox Code Playgroud)

java user-interface multithreading

1
推荐指数
1
解决办法
241
查看次数