解决方案 »

  1.   

    听音乐的话,需要建立A2DP的连接,使用BluetoothA2dpService类Class BluetoothA2dpService int connectSink(String address) 
     int disconnectSink(String address)
      

  2.   

    怎么搞,android api里面也没有这个类啊
      

  3.   

    BluetoothA2dpService是底层的Service类,你可以通过BluetoothA2dp类来使用它android.bluetooth.BluetoothA2dp首先需要绑定BluetoothA2dpService,以下是部分代码:   private BluetoothAdapter mBTAdapter;
       private BluetoothA2dp mBTA2DP;   mBTAdapter = BluetoothAdapter.getDefaultAdapter();
       mBTAdapter.getProfileProxy(mContext, mProfileServiceListener, BluetoothProfile.A2DP);   private BluetoothProfile.ServiceListener mProfileServiceListener = new BluetoothProfile.ServiceListener() {
            @Override
            public void onServiceConnected(int profile, BluetoothProfile proxy) {
                        mBTA2DP = (BluetoothA2dp)proxy;
                        break;
            }
       }   取得mBTA2DP实例后,mBTA2DP.connect(BluetoothDevice device); 即可通过A2DP协议连接外设蓝牙设备
      

  4.   

    但是BluetoothA2dp没有connect()这个方法,编译不能通过啊