Skip to content

Commit

Permalink
Android: Listen for bluetooth connection state changes
Browse files Browse the repository at this point in the history
the headset plug/unplug events only capture wired headset events, trigger event on change of bluetooth device.  Currently does not distinguish on type of event but at least adds basic handling  capability for bluetooth devices.
  • Loading branch information
ghenry22 authored Oct 7, 2021
1 parent 4a2335e commit a4e8dbd
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/android/MusicControls.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ private void registerBroadcaster(MusicControlsBroadcastReceiver mMessageReceiver

// Listen for headset plug/unplug
context.registerReceiver((BroadcastReceiver)mMessageReceiver, new IntentFilter(Intent.ACTION_HEADSET_PLUG));

// Listen for bluetooth connection state changes
context.registerReceiver((BroadcastReceiver)mMessageReceiver, new IntentFilter(android.bluetooth.BluetoothHeadset.ACTION_CONNECTION_STATE_CHANGED));
}

// Register pendingIntent for broacast
Expand Down

0 comments on commit a4e8dbd

Please sign in to comment.