700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > android 连接蓝牙耳机 播放音乐 android 手机怎么实现和蓝牙耳机建立连接 连接之

android 连接蓝牙耳机 播放音乐 android 手机怎么实现和蓝牙耳机建立连接 连接之

时间:2019-08-06 01:52:47

相关推荐

android 连接蓝牙耳机 播放音乐 android 手机怎么实现和蓝牙耳机建立连接 连接之

如题,手机和蓝牙耳机配对之后,怎么建立连接

解决方案

20

BluetoothA2dpService是底层的Service类,你可以通过BluetoothA2dp类来使用它

android.bluetooth.BluetoothA2dp

首先需要绑定BluetoothA2dpService,以下是部分代码:

privateBluetoothAdaptermBTAdapter;

privateBluetoothA2dpmBTA2DP;

mBTAdapter=BluetoothAdapter.getDefaultAdapter();

mBTAdapter.getProfileProxy(mContext,mProfileServiceListener,BluetoothProfile.A2DP);

privateBluetoothProfile.ServiceListenermProfileServiceListener=newBluetoothProfile.ServiceListener(){

@Override

publicvoidonServiceConnected(intprofile,BluetoothProfileproxy){

mBTA2DP=(BluetoothA2dp)proxy;

break;

}

}

取得mBTA2DP实例后,mBTA2DP.connect(BluetoothDevicedevice);即可通过A2DP协议连接外设蓝牙设备

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明android 手机怎么实现和蓝牙耳机建立连接,连接之后可以听音乐!

android 连接蓝牙耳机 播放音乐 android 手机怎么实现和蓝牙耳机建立连接 连接之后可以听音乐...

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。