How to find if the speakerphone is on or not in android

I need to find if the speaker is on or not using programmability.

I know that we can find the method below, regardless of whether it is enabled or not.

AudioManager.isSpeakerphoneOn(); 

in my case even returns false, even if the speaker is turned on somehow.

I need to know below 2 things.

1. Is there any translation action to find the state of the columns.

2. Is there a way to find the status of the speaker status

+4
source share
3 answers

Try this to use the speaker features.

 AudioManager audioManager = (AudioManager) Home.this.getSystemService(Context.AUDIO_SERVICE); audioManager.setSpeakerphoneOn(true); audioManager.setMode(AudioManager.MODE_IN_CALL); 
0
source

Check out the link below. May be helpful.

Turn on the speakerphone for every outgoing call

But the link does not use a broadcast receiver. It checks if the speaker function is turned on at that moment.

0
source

Here you go

 AudioManager audioManager = (AudioManager) MainActivity.this .getSystemService(Context.AUDIO_SERVICE); audioManager.setMode(AudioManager.MODE_IN_CALL); if(audioManager.isSpeakerphoneOn()){ audioManager.setSpeakerphoneOn(true); }else if(!audioManager.isSpeakerphoneOn()){ } 
0
source

Source: https://habr.com/ru/post/1336080/


All Articles