接听电话
mTelecomManager = getSystemService("telecom"); mTelecomManager.acceptRingingCall();
静音
mAudioManager = getSystemService("audio"); mAudioManager.setParameters("incall_music_mute=true");
联发科
耳机插上时 Set_SpeechCall_UL_Mute=1 未插耳机时 Set_SpeechCall_UL_Mute=1;rcv_mux=off
对应地,取消静音则是
Set_SpeechCall_UL_Mute=0 或 Set_SpeechCall_UL_Mute=0;rcv_mux=on
请求音频焦点
.requestAudioFocus()
录音
int buf_len = AudioRecord.getMinBufferSize(16000, 16, 2); audioRecord = new AudioRecord(3, 16000, 16, 2, buf_len); // inputSource=3 (AUDIO_SOURCE_VOICE_DOWNLINK) audioRecord.startRecording(); short[] buf = new short[buf_len]; audioRecord.read(buf, 0, buf_len);
音频源定义
AUDIO_SOURCE_VOICE_UPLINK = 2, AUDIO_SOURCE_VOICE_DOWNLINK = 3, AUDIO_SOURCE_VOICE_CALL = 4,
流媒体类型定义
AUDIO_STREAM_VOICE_CALL = 0, AUDIO_STREAM_SYSTEM = 1, AUDIO_STREAM_RING = 2, AUDIO_STREAM_MUSIC = 3,