android 蓝牙耳机音量,android – 如何使用蓝牙耳机录制声音

olivierg基本上是对的(AudioSource仍然可以是MIC),一些基本的代码将如下所示:

am = (AudioManager) getSystemService(Context.AUDIO_SERVICE);

registerReceiver(new BroadcastReceiver() {

@Override

public void onReceive(Context context, Intent intent) {

int state = intent.getIntExtra(AudioManager.EXTRA_SCO_AUDIO_STATE, -1);

Log.d(TAG, "Audio SCO state: " + state);

if (AudioManager.SCO_AUDIO_STATE_CONNECTED == state) {

/*

* Now the connection has been established to the bluetooth device.

* Record audio or whatever (on another thread).With AudioRecord you can record with an object created like this:

* new AudioRecord(MediaRecorder.AudioSource.MIC, 8000, AudioFormat.CHANNEL_CONFIGURATION_MONO,

* AudioFormat.ENCODING_PCM_16BIT, audioBufferSize);

*

* After finishing, don't forget to unregister this receiver and

* to stop the bluetooth connection with am.stopBluetoothSco();

*/

unregisterReceiver(this);

}

}

}, new IntentFilter(AudioManager.ACTION_SCO_AUDIO_STATE_CHANGED));

Log.d(TAG, "starting bluetooth");

am.startBluetoothSco();

这个我再次偶然发现,我想指出,插槽评论的重要性包括正确的权限,最重要的是设置

在你的清单文件.没有它,您将不会收到任何错误信息,但状态将不会更改为连接.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值