AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); audioManager.setMicrophoneMute(false); tv1.setText("Микрофон: "+audioManager.isMicrophoneMute());
Gives out - "Microphone: true"
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");
Source: https://ru.stackoverflow.com/questions/504988/
All Articles