1
我正在開發一個應用程序,我必須連接到Android 4.3上的Bluetooth Low Energy設備。如何在Android 4.3中實時獲取藍牙設備的RSSI?
當我按下按鈕,我可以得到BLE裝置的RSSI利用BluetoothLeService.readRemoteRssi();
後連接到設備上,但我想要得到的RSSI在每一秒? 我嘗試了Runnable,但它不會在日誌中調用readRemoteRssi();
函數。
最終可運行可運行=新的Runnable(){
@Override
public void run() {
// TODO Auto-generated method stub
mBluetoothLeService.readRemoteRssi();
mHandler.postDelayed(runnable, 1000);
}
};
我應該在哪裏輸入BluetoothLeService.readRemoteRssi();
?
in onResume
??或者怎麼做才能讓APP始終獲得RSSI?
對不起我的英文,我只是新手。
感謝您的指導!
添加
mHandler.postDelayed(runnable, 1000);
感謝您向我們提供的解決方案,因爲我來到了這個兩年後:) – Gannic