diff options
author | Michael Scarito <ms-github@mit.edu> | 2014-11-20 14:14:25 -0800 |
---|---|---|
committer | Michael Scarito <ms-github@mit.edu> | 2014-11-20 14:22:43 -0800 |
commit | d4a3095512a2b1eaf5517699e63f38b4d73546de (patch) | |
tree | dab463b70665d61728a480214d20821d35c59707 /core/src/main/java | |
parent | d15acebd8b688132c8d13f6285e35e9b4b4afcb7 (diff) | |
download | AntennaPod-d4a3095512a2b1eaf5517699e63f38b4d73546de.zip |
Added bluetooth BroadcastReceiver to resume after disconnect
Diffstat (limited to 'core/src/main/java')
-rw-r--r-- | core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java b/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java index a2646b981..b6e87f5ae 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java +++ b/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java @@ -210,6 +210,8 @@ public class PlaybackService extends Service { Intent.ACTION_HEADSET_PLUG)); registerReceiver(shutdownReceiver, new IntentFilter( ACTION_SHUTDOWN_PLAYBACK_SERVICE)); + registerReceiver(bluetoothStateUpdated, new IntentFilter( + AudioManager.ACTION_SCO_AUDIO_STATE_UPDATED)); registerReceiver(audioBecomingNoisy, new IntentFilter( AudioManager.ACTION_AUDIO_BECOMING_NOISY)); registerReceiver(skipCurrentEpisodeReceiver, new IntentFilter( @@ -232,6 +234,7 @@ public class PlaybackService extends Service { unregisterReceiver(headsetDisconnected); unregisterReceiver(shutdownReceiver); + unregisterReceiver(bluetoothStateUpdated); unregisterReceiver(audioBecomingNoisy); unregisterReceiver(skipCurrentEpisodeReceiver); mediaPlayer.shutdown(); @@ -995,6 +998,21 @@ public class PlaybackService extends Service { } }; + private BroadcastReceiver bluetoothStateUpdated = new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + if (StringUtils.equals(intent.getAction(), AudioManager.ACTION_SCO_AUDIO_STATE_UPDATED)) { + int state = intent.getIntExtra(AudioManager.EXTRA_SCO_AUDIO_STATE, -1); + int prevState = intent.getIntExtra(AudioManager.EXTRA_SCO_AUDIO_PREVIOUS_STATE, -1); + if (state == AudioManager.SCO_AUDIO_STATE_CONNECTED) { + if (BuildConfig.DEBUG) + Log.d(TAG, "Received bluetooth connection intent"); + unpauseIfPauseOnDisconnect(); + } + } + } + }; + private BroadcastReceiver audioBecomingNoisy = new BroadcastReceiver() { @Override |