我正在尝试每秒显示检测到设备的蓝牙信号强度(rssi)(
我需要一种方法(想法)来刷新RSSI,或者其他一些方法来每秒测量信号?如果设备连接,是否更容易?
应用程序始终提供恒定值:
Timer()
),但由于接收器生命周期,我无法多次调用onRecive()
。我需要一种方法(想法)来刷新RSSI,或者其他一些方法来每秒测量信号?如果设备连接,是否更容易?
应用程序始终提供恒定值:
应用程序的一部分存储在DeviceName 2b:3c:d5:6c:3x:0X 40 db
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";
}
}};