2012-05-02 1099 views
1

我試圖「抓住」,當藍牙從設備斷開連接。 IM正在使用此代碼:如何知道什麼時候藍牙斷開

if (BluetoothDevice.ACTION_ACL_DISCONNECTED.equals(action)){ 
      deleteNotification(); 
      setWarningState(WarningState.RedWarning); 
      showNotification("You are parked"); 

但是當IM斷開通過關閉遙控設備或通過電話關閉藍牙切換藍牙也不會,如果statment進入這個。

在使用該即時通訊:

BluetoothDevice.ACTION_ACL_CONNECTED.equals(action) 

其還好吧工作(當aconnection是astablished)。 這是爲什麼,我怎麼能使它工作? 謝謝!

回答

4

你有沒有註冊的下方IntenFilters

IntentFilter f1 = new IntentFilter(BluetoothDevice.ACTION_ACL_DISCONNECT_REQUESTED); 
IntentFilter f2 = new IntentFilter(BluetoothDevice.ACTION_ACL_DISCONNECTED); 
this.registerReceiver(mReceiver, f1); 
this.registerReceiver(mReceiver, f2); 
+0

哇!謝謝,一個棘手的錯誤! – roiberg

相關問題