Added toggle to play on Bluetooth device

This commit is contained in:
h4h13 2020-02-20 22:10:45 +05:30
parent d2284f410d
commit 27141c1bd2
4 changed files with 36 additions and 12 deletions

View file

@ -282,9 +282,9 @@ public class MusicService extends Service implements
@Override
public void onReceive(final Context context, final Intent intent) {
String action = intent.getAction();
Log.i(TAG, "onReceive: " + action);
if (action != null) {
if (BluetoothDevice.ACTION_ACL_CONNECTED.equals(action)) {
if (BluetoothDevice.ACTION_ACL_CONNECTED.equals(action) &&
PreferenceUtil.getInstance(context).bluetoothSpeaker()) {
if (VERSION.SDK_INT >= VERSION_CODES.M) {
if (getAudioManager().getDevices(AudioManager.GET_DEVICES_OUTPUTS).length > 0) {
play();