我正在编写一个用于从蓝牙录制音频的 android 应用程序,但我无法在 Android 中通过蓝牙录制音频。你可以看到下面的代码
AudioManager am;
am = (AudioManager) getSystemService(AUDIO_SERVICE);
am.setMode(AudioManager.MODE_IN_CALL);
am.startBluetoothSco();
am.setBluetoothScoOn(true);
Intent intent = getIntent();
if (intent.getBooleanExtra("privacy", false)) {
showServerPrompt(true);
return;
}
// If the Ringdroid media select activity was launched via a
// GET_CONTENT intent, then we shouldn't display a "saved"
// message when the user saves, we should just return whatever
// they create.
mWasGetContentIntent = intent.getBooleanExtra(
"was_get_content_intent", false);
mFilename = intent.getData().toString();
mSoundFile = null;
mKeyDown = false;
if (mFilename.equals("record")) {
try {Intent recordIntent = new Intent(
MediaStore.Audio.Media.RECORD_SOUND_ACTION);
startActivityForResult(recordIntent, REQUEST_CODE_RECORD);
} catch (Exception e) {
showFinalAlert(e, R.string.record_error);
}
}
mHandler = new Handler();
loadGui();
mHandler.postDelayed(mTimerRunnable, 100);
if (!mFilename.equals("record")) {
loadFromFile();
}
}
这在以正常方式使用手机时效果很好。但是,它不会检测到蓝牙耳机的存在,并且即使在耳机插入时仍使用手机自带的麦克风。