Back to project page android-music-player.
The source code is released under:
GNU General Public License
If you think the Android project android-music-player listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package pconley.vamp.player; //from w w w.ja v a2 s. c o m import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.media.AudioManager; /** * Listen for the AudioManager's AUDIO_BECOMING_NOISY intent, and pause the * player if it's running. */ public class AudioNoisyReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { if (intent.getAction() != null && intent.getAction().equals( AudioManager.ACTION_AUDIO_BECOMING_NOISY)) { context.startService(new Intent(context, PlayerService.class) .setAction(PlayerService.ACTION_PAUSE)); } } }