3

I am making an application where I have to give a facility to turn speaker phone on/off during ongoing call. I used AudioManager and its working find till android Oreo devices, but when it comes to android Pie does not work and does not even through any exception or error. Below is the code I have used so far.

AudioManager am = (AudioManager)context.getSystemService(Context.AUDIO_SERVICE);
am.setMode(AudioManager.MODE_IN_CALL);
am.setSpeakerphoneOn(true);

I also used below permission too.

<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />

Am I missing anything with this new android version Pie. I am testing this application with MI REDMI NOTE 8 and MI REDMI NOTE 7 PRO.

Thanks in advance for any correction.

0 Answers0