My application must record sound only from external microphone. Is there a way to get list of available microphones?
I'm using AudioRecord
for sound capturing.
Thanks in advance.
The applicable solution for me I found here . And added the following code:
private static boolean headsetMic;
private static BroadcastReceiver mReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
final String action = intent.getAction();
if (Intent.ACTION_HEADSET_PLUG.equals(action)) {
final int headphones = intent.getIntExtra("state", -1);
final int mic = intent.getIntExtra("microphone", -1);
// we need to check both of them, because if headset with
// mic was disconnected mic is 1 but headphones is 0, and
// actually no external mic is connected
headsetMic = headphones > 0 && mic > 0;
}
}
};
public static boolean isExternalMicConnected() {
return headsetMic;
}
I call isExternalMicConnected()
and it shows if custom mic was connected.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.