Question

I am making a music player where I need to stream some music from URL.

Anyway, I want to control sound from application when I have incoming call or when I recive SMS.

I found that there could be two ways how to do it, with AudioManager and audio focus and with Telephony Manager.

But am not sure which way is better to do it?

Was it helpful?

Solution

If you just want to pause music while you receive and incoming call then you can simply use TelephonyManager to detect an incoming call and pause the music.

Also if you want to pause music while you get any notification sound then you can see the answer How to pause music when phone rings, sms is received, etc?. It fits that need. Also on searching Google using query music pause sms received, I found that many users complained that Android OS itself pause the music while any notification sound is received. Also there was no setting to turn that off. Since I never tried it personally, I can't tell you on which versions that bug was present. You can research yourself or may ask a new question here, hopefully some knows more than myself.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top