我正在尝试从检测到的设备中显示蓝牙信号强度 (rssi) 每隔一秒 ( ),但由于Receiver LifecycleTimer()
,我无法onRecive()
多次调用。
我需要一种方法(想法)来刷新 RSSI,还是需要其他方法来每秒测量一个信号?如果连接设备会更容易吗?
App 总是给出一个常数值:
设备名称 2b:3c:d5:6c:3x:0X 40 分贝
部分应用程序存储在Timer()
方法中:
BroadcastReceiver mReceiver = new BroadcastReceiver() {
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
// When discovery finds a device
if (BluetoothDevice.ACTION_FOUND.equals(action)) {
// Get the BluetoothDevice object from the Intent
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
short rssi = intent.getShortExtra(BluetoothDevice.EXTRA_RSSI,Short.MIN_VALUE);
// Add the name and address to an array adapter to show in a ListView
msg = device.getName() + " " + device.getAddress() + " " +rssi+ " db";
}
}};