react-native-incall-manager icon indicating copy to clipboard operation
react-native-incall-manager copied to clipboard

speaker on/off not working on android 11

Open ghost opened this issue 4 years ago • 6 comments
trafficstars

setSpeakerphoneOn and setForceSpeakerphoneOn not working on android 11 when set speaker, the earphone sounds a little bit less, and the speaker no sound. android 10 is working well.

ghost avatar Apr 22 '21 07:04 ghost

My android 10 not work

Richtervn avatar Jun 16 '21 08:06 Richtervn

updated the setSpeakerphoneOn function on incallmanagermodule

 @ReactMethod
    public void setSpeakerphoneOn(final boolean enable) {
        try {
            Class audioSystemClass = Class.forName("android.media.AudioSystem");
            Method setForceUse = audioSystemClass.getMethod("setForceUse", int.class, int.class);
            setForceUse.invoke(null, 1, 1);
        }catch (Exception err){
            err.printStackTrace();
        }


        if (enable != audioManager.isSpeakerphoneOn())  {
            Log.d(TAG, "setSpeakerphoneOn(): " + enable);
            audioManager.setMode(AudioManager.MODE_IN_COMMUNICATION);
            audioManager.setSpeakerphoneOn(enable);
        }
    }

ghost avatar Jun 16 '21 08:06 ghost

You should add the MODIFY_AUDIO_SETTINGS to the manifest.

lahsuk avatar Dec 07 '21 06:12 lahsuk

I have the same problem. Not working on Android 11-12. Already have MODIFY_AUDIO_SETTINGS , also tried both methods setSpeakerphoneOn and setForceSpeakerphoneOn. Any solution so far ?

dragoshuniq avatar Aug 31 '22 07:08 dragoshuniq

@dragoshuniq i also have same problem...

KolissnikBogdan avatar Aug 31 '22 14:08 KolissnikBogdan

@dragoshuniq try to add this (InCallManagerModule.java) Снимок экрана 2022-09-02 в 17 04 59

KolissnikBogdan avatar Sep 02 '22 14:09 KolissnikBogdan

fixed in #201

zxcpoiu avatar Dec 05 '22 20:12 zxcpoiu