Android蓝牙4.0API内容-接口-BluetoothProfile

Public APIs for the Bluetooth Profiles配置文件. 

Clients should call getProfileProxy(Context, BluetoothProfile.ServiceListener, int), to get the Profile Proxy代理. Each public profile implements this interface.

关于getProfileProxy方法

Get the profile proxy object associated交互 with the profile.

Profile can be one of HEALTHHEADSETA2DPGATT, or GATT_SERVER. Clients must implement BluetoothProfile.ServiceListener to get notified 通知of the connection status and to get the proxy object.

方法中的参数

context  Context: Context of the application

listener  BluetoothProfile.ServiceListener: The service Listener for connection callbacks.

profile    int: The Bluetooth profile; either HEALTHHEADSETA2DPGATT or GATT_SERVER.

返回值类型为boolean

BluetoothProfile.ServiceListener接口描述

An interface for notifying BluetoothProfile IPC clients when they have been connected or disconnected to the service.

通知链接状态

其中的两个方法:1.public abstract vois onServiceConected(int profile,BluetoothProfile proxy)

profile int: - One of HEALTHHEADSET or A2DP

proxy BluetoothProfile: - One of BluetoothHealthBluetoothHeadset or BluetoothA2dp

2.public abstract void onServiceDIsConected(int profile)

profile int: - One of HEALTHHEADSET or A2DP

常量:

String EXTRA_PREVIOUS_STATE

String EXTRA_STATE

int A2DP 蓝牙音频协议

int GATT

int GATT_SERVER

int HEADSET 协议类型

int HEALTH 协议类型

int SAP

int STATE_CONNECTED 链接状态

int STATE_CONNECTING 连接中

int STATE_DISCONNECTED

int STATE_DISCONNECTING

公有的方法

abstract List<BluetoothDevice> getConnectedDevices()

Get connected devices for this specific profile.
获取设备列表
abstract int  getConnectionState( BluetoothDevice device)

  Get the current connection state of the profile

Requires BLUETOOTH permission.

abstratct   List<BluetoothDevicegetDevicesMatchingConnectionStates(int[] states)

Get a list of devices that match any of the given connection states.获取目标链接状态的设备列表


你可能感兴趣的:(Android蓝牙4.0API内容-接口-BluetoothProfile)