AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); audioManager.setMicrophoneMute(false); tv1.setText("Микрофон: "+audioManager.isMicrophoneMute()); 

Gives out - "Microphone: true"

    1 answer 1

    Here they write that this is a common problem and it is solved with a dirty hack of emulating pressing the Mute button on the headset:

     Intent buttonUp = new Intent(Intent.ACTION_MEDIA_BUTTON); buttonUp.putExtra(Intent.EXTRA_KEY_EVENT,new KeyEvent(KeyEvent.ACTION_UP,KeyEvent.KEYCODE_HEADSETHOOK)); getBaseContext().sendOrderedBroadcast(buttonUp,"android.permission.CALL_PRIVILEGED"); 
    • This I saw, of course. Does not work. The result is the same: "Microphone: true" :( - LEO
    • I don’t think that ready-made programs (for example, voice recorders) will use dirty hacks to simulate pressing! - LEO
    • @ LEO can you then open any open source project and see how it is implemented there? Tell us at the same time how to implement it correctly if not by emulation - whalemare