How do you check if music is playing by using a broadcast receiver?

You don’t need a broadcast receiver for this – AudioManager is your friend: AudioManager.isMusicActive() does the job you want, have a closer look here for details: AudioManager here is an example: AudioManager manager = (AudioManager)this.getSystemService(Context.AUDIO_SERVICE); if(manager.isMusicActive()) { // do something – or do it not }

Playing BG Music Across Activities in Android

You can also create a service which play music using mediaplayer as below. Intent svc=new Intent(this, BackgroundSoundService.class); startService(svc); //OR stopService(svc); public class BackgroundSoundService extends Service { private static final String TAG = null; MediaPlayer player; public IBinder onBind(Intent arg0) { return null; } @Override public void onCreate() { super.onCreate(); player = MediaPlayer.create(this, R.raw.idil); player.setLooping(true); // … Read more

Android background music service

Do it without service https://web.archive.org/web/20181116173307/http://www.rbgrn.net/content/307-light-racer-20-days-61-64-completion If you are so serious about doing it with services using mediaplayer Intent svc=new Intent(this, BackgroundSoundService.class); startService(svc); public class BackgroundSoundService extends Service { private static final String TAG = null; MediaPlayer player; public IBinder onBind(Intent arg0) { return null; } @Override public void onCreate() { super.onCreate(); player = MediaPlayer.create(this, R.raw.idil); … Read more