如何知道什么时候断开连接蓝牙 [英] How to know when bluetooth disconnected

查看:979
本文介绍了如何知道什么时候断开连接蓝牙的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图抓时,蓝牙从设备断开连接。
IM在用这个code:

i am trying to "catch" when the bluetooth is disconnected from a device. im am using this code:

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

,但是当即时断开通过关闭远程设备或通过在电话关闭蓝牙切换蓝牙它不会如果说明书。输入此

but when im disconnection the bluetooth by turning off the remote device or by turning off the bluetooth toggle in the phone it will not enter this if statment.

在使用这个即时通讯:

BluetoothDevice.ACTION_ACL_CONNECTED.equals(action)

其还好吧工作(当aconnection是astablished)。
这是为什么,我怎么能使其工作?
谢谢!

its working allright (when aconnection is astablished). why is that and how can i make it work? Thanks!

推荐答案

你有没有注册的下方IntenFilters

Have you registered the below 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);

这篇关于如何知道什么时候断开连接蓝牙的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆