Example usage for android.media AudioManager GET_DEVICES_INPUTS

List of usage examples for android.media AudioManager GET_DEVICES_INPUTS

Introduction

In this page you can find the example usage for android.media AudioManager GET_DEVICES_INPUTS.

Prototype

int GET_DEVICES_INPUTS

To view the source code for android.media AudioManager GET_DEVICES_INPUTS.

Click Source Link

Document

Specifies to the AudioManager#getDevices(int) method to include source (i.e.

Usage

From source file:com.google.sample.aaudio.echo.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    statusText = findViewById(R.id.status_view_text);
    toggleEchoButton = findViewById(R.id.button_toggle_echo);
    toggleEchoButton.setOnClickListener(new View.OnClickListener() {
        @Override/*from  www  . ja v  a 2s.  c  om*/
        public void onClick(View view) {
            toggleEcho();
        }
    });
    toggleEchoButton.setText(getString(R.string.start_echo));

    recordingDeviceSpinner = findViewById(R.id.recording_devices_spinner);
    recordingDeviceSpinner.setDirectionType(AudioManager.GET_DEVICES_INPUTS);
    recordingDeviceSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
            EchoEngine.setRecordingDeviceId(getRecordingDeviceId());
        }

        @Override
        public void onNothingSelected(AdapterView<?> adapterView) {
            // Do nothing
        }
    });

    playbackDeviceSpinner = findViewById(R.id.playback_devices_spinner);
    playbackDeviceSpinner.setDirectionType(AudioManager.GET_DEVICES_OUTPUTS);
    playbackDeviceSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
            EchoEngine.setPlaybackDeviceId(getPlaybackDeviceId());
        }

        @Override
        public void onNothingSelected(AdapterView<?> adapterView) {
            // Do nothing
        }
    });

    EchoEngine.create();
}