2
votes

I try to setMode(mode_in_call) to change audio mode when I play a media. So,i'm sure i add the permission
and i write in code like this: AudioManager mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); mAudioManager.setMode(AudioManager.MODE_IN_CALL);

here is the problem: i use Sumsung i9000 i9023 it doesn't work,and the log Phone Related Audio Settings Permission Denial: setMode() but i try Sony x10 LT15i,it can modify the mode correctly. why doesn't this happen.

2

2 Answers

5
votes

I don't see what permission you say you added but make sure it's:

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

Note that MODE_IN_CALL can only be selected by the main telephony application with permission Manifest.permission.MODIFY_PHONE_STATE.

"Manifest.permission.MODIFY_PHONE_STATE" - Allows modification of the telephony state - power on, mmi, etc. Does not include placing calls. Not for use by third-party applications.

Reference link: https://developer.android.com/reference/android/media/AudioManager#setCommunicationDevice(android.media.AudioDeviceInfo)

https://developer.android.com/reference/android/Manifest.permission#MODIFY_PHONE_STATE