源码介绍:整合目前主流的蓝牙demo源码效果:源码片段:finalBluetoothManagerbluetoothManager=(BluetoothManager)getSystemService(Context.BLUETOOTH_SERVICE);mBluetoothAdapter=bluetoothManager.getAdapter();//ChecksifBluetoothManagerbluetoothManager=(BluetoothManager)getSystemService(Context.BLUETOOTH_SERVICE);mBluetoothAdapter=bluetoothManager.getAdapter();//ChecksifBluetooththissupportedonthedevice.Adapter(m=null){Toast.makeText(this,R.string.error_bluetooth_not_supported,Toast.LENGTH_SHORT).show();finish();return;}//开启蓝牙mBluetoothAdapter.enable();mBLE=newBluetoothLeClass(this);if(!mBLE.initialize()){Log.e(TAG,"UnabletoinitializeBluetooth");finish();}//找到BLE端的Service时回调mBLE.setOnServiceDiscoverListener(mOnServiceDiscover);//接收BLE终端的数据交互EventmBLE.setOnDataAvailableListener(mOnDataAvailable);下载地址:http://down.51cto.com/data/2096560
