蓝牙4.0BLE开发

移动开发
集成目前主流蓝牙的demo

源码简介:集成目前主流蓝牙的demo

源码效果:

源码片段:

  1. final BluetoothManager bluetoothManager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE); 
  2. mBluetoothAdapter = bluetoothManager.getAdapter(); 
  3.    
  4. // Checks if Bluetooth is supported on the device. 
  5. if (mBluetoothAdapter == null) { 
  6.     Toast.makeText(this, R.string.error_bluetooth_not_supported, 
  7.             Toast.LENGTH_SHORT).show(); 
  8.      finish(); 
  9.      return
  10. // 开启蓝牙 
  11. mBluetoothAdapter.enable(); 
  12.    
  13. mBLE = new BluetoothLeClass(this); 
  14. if (!mBLE.initialize()) { 
  15.     Log.e(TAG, "Unable to initialize Bluetooth"); 
  16.     finish(); 
  17. // 发现BLE终端的Service时回调 
  18. mBLE.setOnServiceDiscoverListener(mOnServiceDiscover); 
  19. // 收到BLE终端数据交互的事件 
  20. mBLE.setOnDataAvailableListener(mOnDataAvailable); 

下载地址:http://down.51cto.com/data/2096560

责任编辑:倪明 来源: devstore
相关推荐

2022-01-25 16:54:14

BLE操作系统鸿蒙

2023-03-08 21:30:33

2021-10-30 07:55:00

BLE 蓝牙开发

2023-04-17 16:10:14

鸿蒙蓝牙

2022-11-17 15:26:06

低功耗蓝牙鸿蒙

2023-09-19 15:58:13

Zigbee蓝牙

2015-02-27 16:03:26

Android源码Bluetooth_4BLE蓝牙通信

2010-10-29 09:44:29

Wi-Fi直连蓝牙4.0

2010-07-07 10:32:33

蓝牙无线

2024-01-18 15:24:06

Rust开发鸿蒙OH4.0

2011-06-08 12:42:08

Android 蓝牙

2010-04-29 15:58:40

蓝牙4.0

2023-09-20 11:46:54

蓝牙物联网IOT

2011-08-22 13:46:15

iPhone开发GameKit 蓝牙

2009-09-03 17:42:07

C#开发CF蓝牙模块

2012-07-30 14:57:35

Android 开发者

2010-09-10 10:46:58

Firefox 4.0

2010-09-08 11:26:26

Windows PhoXNA 4.0 3D游戏开发

2016-01-12 16:05:07

WiFiHaLow

2018-12-09 16:18:38

物联网无线技术通信
点赞
收藏

51CTO技术栈公众号