如题,手机和蓝牙耳机配对之后,怎么建立连接
解决方案
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 手机怎么实现和蓝牙耳机建立连接 连接之后可以听音乐...
如果觉得《android 连接蓝牙耳机 播放音乐 android 手机怎么实现和蓝牙耳机建立连接 连接之》对你有帮助,请点赞、收藏,并留下你的观点哦!