1 / 9
文档名称:

2020年SPP蓝牙总结新版培训教材.docx

格式:docx   大小:47KB   页数:9页
下载后只包含 1 个 DOCX 格式的文档,没有任何的图纸或源代码,查看文件列表

如果您已付费下载过本站文档,您可以点这里二次下载

分享

预览

2020年SPP蓝牙总结新版培训教材.docx

上传人:读书百遍 2020/3/2 文件大小:47 KB

下载得到文件列表

2020年SPP蓝牙总结新版培训教材.docx

文档介绍

文档介绍: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