android-BluetoothManager

BluetoothManager

public final class BluetoothManager 
extends Object 

java.lang.Object
   ↳ android.bluetooth.BluetoothManager


High level manager used to obtain an instance of an BluetoothAdapter and to conduct overall Bluetooth Management.

高级管理者用于获得BluetoothAdapter的实例并进行整体蓝牙管理

Use getSystemService(java.lang.String) with BLUETOOTH_SERVICE to create an BluetoothManager, then call getAdapter() to obtain theBluetoothAdapter.

使用getSystemService(String)创建一个BluetoothManager BLUETOOTH_SERVICE,然后调用getAdapter()来获得theBluetoothAdapter。

Alternately, you can just call the static helper getDefaultAdapter().

或者,你可以调用静态辅助getDefaultAdapter()。

Developer Guides

For more information about using BLUETOOTH, read the Bluetooth developer guide.

Summary


Public methods

BluetoothAdapter getAdapter()

Get the default BLUETOOTH Adapter for this device.

这个设备的默认蓝牙适配器。

List<BluetoothDevice> getConnectedDevices(int profile)

Get connected devices for the specified profile.
获得指定的配置文件的连接设备。

int getConnectionState(BluetoothDevice device, int profile)

Get the current connection state of the profile to the remote device.

获取当前状态概要文件的远程设备的连接。

List<BluetoothDevice> getDevicesMatchingConnectionStates(int profile, int[] states)

Get a list of devices that match any of the given connection states.

得到的设备列表匹配任何给定的连接状态。

BluetoothGattServer openGattServer(Context context, BluetoothGattServerCallback callback)

Open a GATT Server The callback is used to deliver results to Caller, such as connection status as well as the results of any other GATT server operations.

打开一个GATT 服务器回调用于向调用者提供的结果,如连接状态以及任何其他GATT 服务器操作的结果。

Inherited methods

From class java.lang.Object

Public methods


getAdapter

Added in  API level 18
BluetoothAdapter getAdapter ()

Get the default BLUETOOTH Adapter for this device.

Returns
BluetoothAdapter the default BLUETOOTH Adapter

getConnectedDevices

Added in  API level 18
List<BluetoothDevice> getConnectedDevices (int profile)

Get connected devices for the specified profile.

Return the set of devices which are in state STATE_CONNECTED
返回设备的设置在STATE_CONNECTED状态

This is not specific to any application configuration but represents the connection state of Bluetooth for this profile. This can be used by applications like status bar which would just like to know the state of Bluetooth.

这不是特定于任何应用程序配置,但这个概要文件代表了蓝牙的连接状态。这可以通过应用程序状态栏,想知道蓝牙的状态。

Requires BLUETOOTH permission.

Parameters
profile int: GATT or GATT_SERVER
Returns
List<BluetoothDevice> List of devices. The list will be empty on error.

getConnectionState

Added in  API level 18
int getConnectionState (BluetoothDevice device, 
                int profile)

Get the current connection state of the profile to the remote device.

获取当前状态概要文件的远程设备的连接。

This is not specific to any application configuration but represents the connection state of the local Bluetooth adapter for certain profile. This can be used by applications like status bar which would just like to know the state of Bluetooth.


这不是特定于任何应用程序配置但代表本地蓝牙适配器连接状态的某些配置文件。这可以通过应用程序状态栏,想知道蓝牙的状态。

Requires BLUETOOTH permission.

Parameters
device BluetoothDevice: Remote bluetooth device.
profile int: GATT or GATT_SERVER
Returns
int State of the profile connection. One of STATE_CONNECTEDSTATE_CONNECTINGSTATE_DISCONNECTEDSTATE_DISCONNECTING

getDevicesMatchingConnectionStates

Added in  API level 18
List<BluetoothDevice> getDevicesMatchingConnectionStates (int profile, 
                int[] states)

Get a list of devices that match any of the given connection states.

If none of the devices match any of the given states, an empty list will be returned.

This is not specific to any application configuration but represents the connection state of the local Bluetooth adapter for this profile. This can be used by applications like status bar which would just like to know the state of the local adapter.

Requires BLUETOOTH permission.

Parameters
profile int: GATT or GATT_SERVER
states int: Array of states. States can be one of STATE_CONNECTEDSTATE_CONNECTINGSTATE_DISCONNECTEDSTATE_DISCONNECTING,
Returns
List<BluetoothDevice> List of devices. The list will be empty on error.

openGattServer

Added in  API level 18
BluetoothGattServer openGattServer (Context context, 
                BluetoothGattServerCallback callback)

Open a GATT Server The callback is used to deliver results to Caller, such as connection status as well as the results of any other GATT server operations. The method returns a BluetoothGattServer instance. You can use BluetoothGattServer to conduct GATT server operations.

Parameters
context Context: App context
callback BluetoothGattServerCallback: GATT server callback handler that will receive asynchronous callbacks.
Returns
BluetoothGattServer BluetoothGattServer instance
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值