首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >安卓JB广播接收器未接收bluetooth.android.bluetooth.BluetoothDevice.ACTION_ACL_CONNECTED

安卓JB广播接收器未接收bluetooth.android.bluetooth.BluetoothDevice.ACTION_ACL_CONNECTED
EN

Stack Overflow用户
提问于 2012-08-29 07:16:42
回答 3查看 2.8K关注 0票数 1

我使用的是一款运行jb的三星galaxy nexus手机,由于某种原因,我没有收到来自蓝牙连接服务的任何广播意向。下面你会发现我的接收器清单和广播接收器代码。任何建议或想法都将不胜感激。

谢谢

这就是宣言

代码语言:javascript
复制
<receiver android:name=".ABroadcastReciever" >
<intent-filter>
<action android:name="android.bluetooth.BluetoothDevice.ACTION_ACL_CONNECTED" />
<action android:name="android.bluetooth.BluetoothDevice.ACTION_ACL_DISCONNECTED" />
<action android:name="android.bluetooth.BluetoothDevice.ACTION_BOND_STATE_CHANGED" />
<action android:name="android.bluetooth.BluetoothDevice.ACTION_FOUND" />
<action android:name="android.bluetooth.BluetoothDevice.BOND_BONDING" />
<action android:name="android.bluetooth.BluetoothDevice.ACTION_ACL_DISCONNECT_REQUESTED" />
<action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
</intent-filter>
</receiver>

这是接收器

代码语言:javascript
复制
public void onReceive(Context context, Intent intent) { 
            String action = intent.getAction();

            //This is looking for the Wifi Connectivity Changes
            if(action.equals("android.net.conn.CONNECTIVITY_CHANGE")){
                Log.d(TAG,"received: Wifi Connection Change");          
            }
            //This is looking Bluetooth connection disconnect 
            else if(action.equals("android.bluetooth.BluetoothDevice.ACTION_ACL_DISCONNECTED") ||
            action.equals("android.bluetooth.BluetoothDevice.ACTION_ACL_DISCONNECTED_REQUESTED") ){
                Log.d(TAG,"Received: Bluetooth Disconnected");

            }
            //This is looking for Bluetooth connection established
            else if(action.equals("android.bluetooth.BluetoothDevice.ACTION_ACL_CONNECTED")){
    Log.d(TAG,"Received: Bluetooth Connected");
            }
        }
EN

回答 3

Stack Overflow用户

发布于 2012-08-30 01:20:39

这是正在传播的新意图。

代码语言:javascript
复制
<action android:name="android.bluetooth.a2dp.profile.action.CONNECTION_STATE_CHANGED" />

感谢您查看这里是新的意图

票数 2
EN

Stack Overflow用户

发布于 2013-04-01 04:43:09

我不知道我是否正确,但我认为这一行是错误的:

代码语言:javascript
复制
<action android:name="android.bluetooth.BluetoothDevice.ACTION_ACL_CONNECTED" />

应该是这个:

代码语言:javascript
复制
<action android:name="android.bluetooth.device.ACTION_ACL_CONNECTED" />

其他人也是一样。将"BluetoothDevice“改为"device”。

在broascast中也是一样的:

代码语言:javascript
复制
if(action.equals("android.bluetooth.BluetoothDevice.ACTION_ACL_CONNECTED"))

应该是

代码语言:javascript
复制
if(action.equals("android.bluetooth.device.action.ACL_CONNECTED"))

更改device.action.ACL_CONNECTED的BluetoothDevice.ACTION_ACL_CONNECTED

票数 1
EN

Stack Overflow用户

发布于 2015-05-14 09:20:54

您的意图筛选器操作不正确。您实际上想要使用以下内容:

<action android:name="android.bluetooth.device.action.ACL_CONNECTED" />

您可以在official Android BluetoothDevice documentation中找到这些值(查看常量值)。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12168874

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档