Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Audiomanager Speaker not working

I'm trying to enable the speaker while I am in a call:

final AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
audioManager.setSpeakerphoneOn(true);

I tried to check after the setSpeakerphoneOn() the audiomanager and get that the speaker is still not on by asking isSpeakerphoneOn()

audioManager.isSpeakerphoneOn();

In my log I can see some errors that I can't understand:

E/AudioManager: Don't setBluetoothScoOn-PackageName: com.myapp.app  on = false
E/AudioManager: Don't setSpeakerphoneOn-PackageName: com.myapp.app  on = true

I can't find anything about this error in the forum.

Didn't work on devices: ZTE Z981, Huawei p9, I already tried this, and android.permission.MODIFY_AUDIO_SETTINGS is granted.

like image 788
motis10 Avatar asked Apr 04 '17 16:04

motis10


1 Answers

Hi read android developer article

https://developer.android.com/reference/android/media/AudioManager.html

explain it clearly

you need to set Permission: MODIFY_AUDIO_SETTINGS in manifest

add this line in manifest

<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
like image 161
Mohammad Hossein jfp Avatar answered Oct 12 '22 17:10

Mohammad Hossein jfp