Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Speakers ON & Off issue while Handling Calls programmatically in android

I am working on an application that is handling incoming and outgoing calls. I am able to handle Incoming and outgoing calls Successfully using Telephony manager.

The issue what i am facing here is Turn Speaker Phone on and off is not working properly only for Samsung S3 and Nexus Devices(Speakers is turning on with Noise). It is working good in Samsung Duos and Micromax.

Please tell me is there any additional code i need to use to make it work.

audioManager.setMode(AudioManager.MODE_IN_CALL);    


if (audioManager.isSpeakerphoneOn()) {
    audioManager.setSpeakerphoneOn(false);
} else {
    audioManager.setSpeakerphoneOn(true);
}
like image 427
user3350497 Avatar asked Feb 20 '26 12:02

user3350497


1 Answers

Do not change mode of audioManager.

i.e. remove line :- audioManager.setMode(AudioManager.MODE_IN_CALL);

If you change mode of audio manager then you need to restore it to previous mode also after ending a call.

like image 90
maveroid Avatar answered Feb 22 '26 00:02

maveroid



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!