I am creating an application in which in have to detect music player states like playing, pause, stop.
i searched and found
AudioManager manager = (AudioManager) FlashLightActivity.this.getSystemService(Context.AUDIO_SERVICE);
if(manager.isMusicActive())
{
Toast.makeText(FlashLightActivity.this, "Music is playing..", Toast.LENGTH_LONG).show();
}else{
Toast.makeText(FlashLightActivity.this, "Music has stopped..", Toast.LENGTH_LONG).show();
}
By using above code i am not able to detect music state if my application is in running mode.
Above code will check this condition at starting of the application. i wanna use broadcast receiver for detecting the state of background music.