在之前的讨论中,考虑了app间通过发起连接提示,来实现类似的门铃提醒功能,
【Android】蓝牙门铃的实现--蓝牙设备的扫描_aaajj的博客-CSDN博客
但是app的操作不如按钮操作方便,
利用蓝牙手柄的connect广播,我们可以把蓝牙手柄作为一个遥控按钮,
开始的时候,手柄和手机使用蓝牙匹配好,
应用中增加对ACTION_ACL_CONNECTED的监听,在手柄蓝牙打开的时候,应用就在可以收到广播了。
/**
* Broadcast Action: Indicates a low level (ACL) connection has been
* established with a remote device.
* <p>Always contains the extra field {@link #EXTRA_DEVICE}.
* <p>ACL connections are managed automatically by the Android Bluetooth
* stack.
* <p>Requires {@link android.Manifest.permission#BLUETOOTH} to receive.
*/
@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
public static final String ACTION_ACL_CONNECTED =
"android.bluetooth.device.action.ACL_CONNECTED";
蓝牙设备的使用可以参考
Android中蓝牙的使用_淼森007的博客-CSDN博客_android 蓝牙