aboutsummaryrefslogtreecommitdiff
path: root/app/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main')
-rw-r--r--app/src/main/AndroidManifest.xml6
-rw-r--r--app/src/main/java/github/daneren2005/dsub/service/DownloadService.java8
2 files changed, 8 insertions, 6 deletions
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index cfc70a55..52756534 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -166,12 +166,6 @@
</intent-filter>
</receiver>
- <receiver android:name="github.daneren2005.dsub.receiver.AudioNoisyReceiver">
- <intent-filter android:priority="999">
- <action android:name="android.media.AUDIO_BECOMING_NOISY" />
- </intent-filter>
- </receiver>
-
<receiver android:name="github.daneren2005.dsub.receiver.A2dpIntentReceiver">
<intent-filter>
<action android:name="android.music.playstatusrequest"/>
diff --git a/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java b/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java
index 6c3cfbd7..f4bc2343 100644
--- a/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java
+++ b/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java
@@ -42,6 +42,7 @@ import github.daneren2005.dsub.domain.PodcastEpisode;
import github.daneren2005.dsub.domain.RemoteControlState;
import github.daneren2005.dsub.domain.RepeatMode;
import github.daneren2005.dsub.domain.ServerInfo;
+import github.daneren2005.dsub.receiver.AudioNoisyReceiver;
import github.daneren2005.dsub.receiver.MediaButtonIntentReceiver;
import github.daneren2005.dsub.util.ArtistRadioBuffer;
import github.daneren2005.dsub.util.ImageLoader;
@@ -77,6 +78,7 @@ import android.content.ComponentCallbacks2;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
+import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.media.AudioManager;
import android.media.MediaPlayer;
@@ -180,6 +182,9 @@ public class DownloadService extends Service {
private boolean autoPlayStart = false;
private boolean runListenersOnInit = false;
+ private IntentFilter audioNoisyIntent = new IntentFilter(AudioManager.ACTION_AUDIO_BECOMING_NOISY);
+ private AudioNoisyReceiver audioNoisyReceiver = new AudioNoisyReceiver();
+
private MediaRouteManager mediaRouter;
// Variables to manage getCurrentPosition sometimes starting from an arbitrary non-zero number
@@ -1328,6 +1333,7 @@ public class DownloadService extends Service {
} else if(playerState == PAUSED_TEMP) {
setPlayerState(temp ? PAUSED_TEMP : PAUSED);
}
+ unregisterReceiver(audioNoisyReceiver);
} catch (Exception x) {
handleError(x);
}
@@ -1352,6 +1358,7 @@ public class DownloadService extends Service {
} else if(playerState == PAUSED) {
setPlayerState(STOPPED);
}
+ unregisterReceiver(audioNoisyReceiver);
} catch(Exception x) {
handleError(x);
}
@@ -1371,6 +1378,7 @@ public class DownloadService extends Service {
autoPlayStart = true;
}
}
+ registerReceiver(audioNoisyReceiver, audioNoisyIntent);
setPlayerState(STARTED);
} catch (Exception x) {
handleError(x);