【发布时间】:2018-11-27 19:40:40
【问题描述】:
我的手机已连接自拍杆。我可以使用以下代码找到设备 ID:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
IntentFilter filter = new IntentFilter(BluetoothDevice.ACTION_ACL_CONNECTED);
this.registerReceiver(mReceiver, filter);
}
//The BroadcastReceiver that listens for bluetooth broadcasts
private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
if (BluetoothDevice.ACTION_ACL_CONNECTED.equals(action)) {
//Device is now connected
Toast.makeText(getApplicationContext(), "ACTION_ACL_CONNECTED" + device, Toast.LENGTH_LONG).show();
}
}
};
我的问题是如何检测此连接的外围设备的按钮按下/单击事件?
以代码 sn-p/tutorial/cmets 形式提供的帮助非常值得赞赏。 谢谢!!!
编辑:
当我按下自拍杆音量+按钮时,听事件
【问题讨论】:
-
你有解决办法吗,如果有请分享一下
-
@YogeshSeralia,是的,我找到了解决方案。请参阅我发布的答案。
标签: android bluetooth bluetooth-lowenergy android-bluetooth