【发布时间】:2018-01-09 18:37:36
【问题描述】:
我有以下接收器(非常简单):
bluetoothReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(BluetoothDevice.ACTION_ACL_DISCONNECTED)) {
stopMusic();
}
}
};
ctx.registerReceiver(bluetoothReceiver, new IntentFilter(BluetoothDevice.ACTION_ACL_DISCONNECTED));
权限:
<uses-permission android:name="android.permission.BLUETOOTH" />
我想做的是在BT耳机断开连接时停止音乐。它可以工作,但是响应时间不好 - 音乐从设备持续大约一秒钟,直到接收器检测到事件。我检查了 Youtube 应用程序,这种情况几乎可以立即运行,无需从设备的扬声器播放任何音乐。知道如何让广播接收器立即检测到ACTION_ACL_DISCONNECTED 吗?
【问题讨论】:
标签: android bluetooth broadcastreceiver