Skip to content

用途:封装了Android蓝牙(经典class和低功耗BLE)所有方法,使蓝牙开发变的简单

Notifications You must be signed in to change notification settings

Dazhi528/RootBluetooth

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

meLibBluetooth

用途:封装了Android蓝牙所有方法,使蓝牙开发变的简单

项目结构及使用说明

library 是库的源码
sample 是用此库的实例

蓝牙库方法说明

UtBt 静态工具类

获得蓝牙适配器
// 获得经典(传统)蓝牙适配器
UtBt.getBtDefAdapter()

// 获得BLE(低功耗)蓝牙适配器
UtBt.getBtDefAdapter()

打开设备的蓝牙
// 本常量用于在onActivityResult方法中判断打开结果
UtBt.LIBINTENT_BT_RQSTENABLE

// 打开设备的蓝牙
UtBt.openBt(Activity activity)

获得已配对的设备List集合
// 本方法用于获得list集合类型的已配对蓝牙设备
UtBt.getBtPairedList(BluetoothAdapter bluetoothAdapter)

配对/取消配对
// 配对
UtBt.btCreateBond()

// 取消配对
UtBt.btRemoveBond()

启用可检测性
// 开此可以让其他设备发现自己; discoverTime范围0~3600秒,设置0为设备始终可检测到
UtBt.openDiscoverable(Context context, int discoverTime)

搜索其他可配对设备
// 经典蓝牙 开始/停止 查找设备
UtBt.FoundBtReceiver startFoundBtDefDevice(Context context, BluetoothAdapter bluetoothAdapter, UtBt.InteLibBtDevice inteLibBtDevice)

UtBt.stopFoundBtDefDevice(Context context, BluetoothAdapter bluetoothAdapter, UtBt.FoundBtReceiver foundBtReceiver)

// BLE蓝牙 开始/停止 查找设备
BtBleScanCall startFoundBtBleDevice(final BluetoothAdapter bluetoothAdapter, final InteLibBtDevice inteLibBtDevice)

UtBt.stopFoundBtBleDevice(final BluetoothAdapter bluetoothAdapter, final InteLibBtDevice inteLibBtDevice, final BtBleScanCall btBleScanCall)

UtBt.InteLibBtDevice
// 查找到设备后,会回调到本方法中
void callBtDevice(BluetoothDevice bluetoothDevice);

// 停止搜索设备时,会回调此方法
void callBtDiscoveryFinished();

About

用途:封装了Android蓝牙(经典class和低功耗BLE)所有方法,使蓝牙开发变的简单

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages