藍(lán)牙4.0BLE開(kāi)發(fā)
作者:zhouzhenhua 
  集成目前主流藍(lán)牙的demo
 源碼簡(jiǎn)介:集成目前主流藍(lán)牙的demo
源碼效果:
源碼片段:
- final BluetoothManager bluetoothManager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);
 - mBluetoothAdapter = bluetoothManager.getAdapter();
 - // Checks if Bluetooth is supported on the device.
 - if (mBluetoothAdapter == null) {
 - Toast.makeText(this, R.string.error_bluetooth_not_supported,
 - Toast.LENGTH_SHORT).show();
 - finish();
 - return;
 - }
 - // 開(kāi)啟藍(lán)牙
 - mBluetoothAdapter.enable();
 - mBLE = new BluetoothLeClass(this);
 - if (!mBLE.initialize()) {
 - Log.e(TAG, "Unable to initialize Bluetooth");
 - finish();
 - }
 - // 發(fā)現(xiàn)BLE終端的Service時(shí)回調(diào)
 - mBLE.setOnServiceDiscoverListener(mOnServiceDiscover);
 - // 收到BLE終端數(shù)據(jù)交互的事件
 - mBLE.setOnDataAvailableListener(mOnDataAvailable);
 
責(zé)任編輯:倪明 
                    來(lái)源:
                    devstore
 















 
 
 








 
 
 
 