How do I write this Android App? Automatic change of Audio Output Mode

1.6k views Asked by At

My device is an Android MiniTV mk808c.

The device defaults the Audio Output to audio_hdmi. I need the device to default to audio_codec OR change to audio_codec automatically. I can do this manually via a menu under settings->sound->audio output

From what I understand "audio output mode is a setting - audio.routing. It accepts the values 2 (CODEC), 1024 (HDMI) and 4096 (S/PDIF). "

Any help would be greatly appreciated. I need to write a one line app or if you have any other idea?

2

There are 2 answers

2
jdm On
    audioManager = (AudioManager) getApplicationContext().getSystemService(Context.AUDIO_SERVICE);
    audioManager.setParameters("audio_devices_out_active=AUDIO_CODEC");
0
Prabakaran On

audioManager = (AudioManager) getApplicationContext().getSystemService(Context.AUDIO_SERVICE); audioManager.setParameters("audio_devices_out_active=AUDIO_CODEC");

The above code is correct. But it needs the below permission to work in AndroidManifest.xml

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