public class BluetoothHelper
extends java.lang.Object
desc : 蓝牙匹配辅助类(单例)
author : xuexiang
time : 2018/4/28 上午1:15
| Modifier and Type | Class and Description |
|---|---|
static interface |
BluetoothHelper.OnBluetoothDeviceListener
蓝牙设备监听器
|
static interface |
BluetoothHelper.OnSearchDeviceListener
设备扫描的监听
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
createBind(android.bluetooth.BluetoothDevice btDevice)
弹出蓝牙连接的方法
|
boolean |
createBind(android.bluetooth.BluetoothDevice btDevice,
java.lang.String pingCode)
蓝牙匹配的方法
|
static BluetoothHelper |
get() |
android.bluetooth.BluetoothAdapter |
getBluetoothAdapter() |
android.bluetooth.BluetoothDevice |
getBluetoothDevice(java.lang.String address)
根据地址获取蓝牙设备
|
IBluetoothDeviceFilter |
getBluetoothDeviceFilter() |
boolean |
isBluetoothBond(java.lang.String address)
蓝牙是否已绑定
|
boolean |
isBtAddressValid(java.lang.String address)
检验蓝牙地址的有效性
|
boolean |
isCorrectDevice(android.bluetooth.BluetoothDevice device)
是否是指定的蓝牙设备
|
boolean |
isCorrectDevice(java.lang.String address)
蓝牙设备是否正确
|
boolean |
isOpenBluetooth()
是否已经开启蓝牙
|
void |
openBluetooth(boolean isReOpen)
开启蓝牙
|
boolean |
pairBtDevice(java.lang.String address)
根据地址匹配具体的蓝牙设备
|
void |
release()
资源释放
|
void |
searchDevices(BluetoothHelper.OnBluetoothDeviceListener listener)
扫描蓝牙设备
|
BluetoothHelper |
setBluetoothDeviceFilter(IBluetoothDeviceFilter deviceFilter)
设置蓝牙设备过滤器
|
BluetoothHelper |
setOnBluetoothDeviceListener(BluetoothHelper.OnBluetoothDeviceListener listener)
设置蓝牙设备监听
|
boolean |
startSearch()
开始扫描蓝牙
|
void |
stopSearch()
停止扫描蓝牙
|
public static BluetoothHelper get()
public void openBluetooth(boolean isReOpen)
isReOpen - 是否是重新打开蓝牙public boolean startSearch()
public void stopSearch()
public void searchDevices(BluetoothHelper.OnBluetoothDeviceListener listener)
listener - 蓝牙设备监听器public boolean createBind(android.bluetooth.BluetoothDevice btDevice)
throws java.lang.Exception
btDevice - java.lang.Exceptionpublic boolean createBind(android.bluetooth.BluetoothDevice btDevice,
java.lang.String pingCode)
btDevice - java.lang.Exceptionpublic boolean pairBtDevice(java.lang.String address)
address - public boolean isOpenBluetooth()
public boolean isBtAddressValid(java.lang.String address)
address - 蓝牙地址public boolean isCorrectDevice(java.lang.String address)
address - public boolean isCorrectDevice(android.bluetooth.BluetoothDevice device)
device - public boolean isBluetoothBond(java.lang.String address)
address - public void release()
public BluetoothHelper setOnBluetoothDeviceListener(BluetoothHelper.OnBluetoothDeviceListener listener)
listener - public BluetoothHelper setBluetoothDeviceFilter(IBluetoothDeviceFilter deviceFilter)
deviceFilter - public IBluetoothDeviceFilter getBluetoothDeviceFilter()
public android.bluetooth.BluetoothAdapter getBluetoothAdapter()
public android.bluetooth.BluetoothDevice getBluetoothDevice(java.lang.String address)
address -