如何获得蓝牙装置的RSSI在实时的Android 4.3? [英] How to get the RSSI of bluetooth device in real time in Android 4.3?
问题描述
我开发一个应用程序,其中我需要连接到蓝牙低功耗设备在Android 4.3。
I am developing an application where I have to connect to Bluetooth Low Energy device on Android 4.3.
当我按下按钮,我可以得到BLE装置的RSSI后连接到该设备使用 BluetoothLeService.readRemoteRssi();
When I push the button, I can get the RSSI of the BLE device after connect to the device by using BluetoothLeService.readRemoteRssi();
不过,我想要得到的RSSI在每一秒?
我已经尝试了Runnable,但它简化版,叫 readRemoteRssi();
在日志功能
But I want to get the RSSI in every second ??
I have try the Runnable, but it does't call the readRemoteRssi();
function in log.
最终可运行可运行=新的Runnable(){
final Runnable runnable = new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
mBluetoothLeService.readRemoteRssi();
mHandler.postDelayed(runnable, 1000);
}
};
我应该在哪里键入 BluetoothLeService.readRemoteRssi();
??
Where should I type the BluetoothLeService.readRemoteRssi();
??
在 onResume
?或者怎么做才能让APP总是得到RSSI ??
in onResume
?? or how to do can let the APP always get the RSSI ??
对不起,我的英语和我只是新来这个。
Sorry for my English and I am just new to this.
感谢您的方向!
推荐答案
我解决这个问题。
修改下面的code:
final Runnable runnable = new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
mBluetoothLeService.readRemoteRssi();
mHandler.postDelayed(this, 1000);
}
};
和增加 mHandler.postDelayed(可运行,1000);
在的onCreate
这篇关于如何获得蓝牙装置的RSSI在实时的Android 4.3?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!