文档介绍:SPP蓝牙总结SPP蓝牙使用<uses-permissionandroid:name=""/><uses-permissionandroid:name=""/>添加权限蓝牙搜索IntentFilterfilter=newIntentFilter();();();(mReceiver,filter);();开始扫描外围设备退出,停止搜索,();privatevoidunregisterReceiver(){if(mReceiverRegisted&&mContext!=null){(mReceiver);mReceiverRegisted=false;}}蓝牙连接mConnectThread=newConnectThread(device,secure);();新建连接线程并启动privateclassConnectThreadextendsThread{privatefinalBluetoothSocketmmSocket;privatefinalBluetoothDevicemmDevice;privateStringmSocketType;onnectThread(BluetoothDevicedevice,booleansecure){mmDevice=device;BluetoothSockettmp=null;mSocketType=secure?"Secure":"Insecure";try{if(secure){tmp=(SPP_UUID);}else{tmp=(SPP_UUID);}}catch(IOExceptione){}mmSocket=tmp;}publicvoidrun(){setName("ConnectThread"+mSocketType);if(mmSocket!=null){try{();}catch(IOExceptione){try{();}catch(IOExceptione2){}connectionFailed(mmDevice);return;}synchronized(){mConnectThread=null;}mCount=0;connected(mmSocket,mmDevice,mSocketType);}}b)创立Bl