Search code examples
androidandroid-studiovolumemicrophonepjsip

How to increase Microphone volume level in Android PJSIP?


I have Integrated PJSIP with android. While making call in my application, the Speaker is working perfectly but Recording microphone volume is too low. My voice is not hearable by other side.

Note: But in some mobiles it's working properly.

Even i tried with adjustStreamVolume(), setStreamVolume(), setMode(),adjustVolume() methods to increase my volume level, it doesn't increase in anyway. Please give me a suggestion to solve this problem to increasing microphone Volume level in Android or from PJSIP.

Thanks in Advance.


Solution

  • Problem is Microphone volume level is too low when our application access through microphone. When you got low volume, you need to check multiple things.

    One of them is MODE OF THE AUDIO MANAGER when microphone is used.

    Getting MODE of the Android Audio manager::

    AudioManager am = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
    long mode = am.getMode();   
    Log.e(TAG,"audio mode "+mode);
    

    Setting MODE of the Android Audio manager::

    AudioManager am = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
    am.setMode(3);
    

    You can access the mode of audio manager through this above code for your app. There are
    1.MODE_NORMAL
    2.MODE_RINGTONE
    3.MODE_IN_CALL
    4.MODE_IN_COMMUNICATION

    P.S. : Whenever you change the mode of the AudioManager, please change into MODE_NORMAL after using microphone otherwise it won't work once you restart the mobile.