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 HEALTH
, HEADSET
, A2DP
, GATT
, 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 HEALTH
, HEADSET
, A2DP
. GATT
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 HEALTH
, HEADSET
or A2DP
proxy BluetoothProfile
: - One of BluetoothHealth
, BluetoothHeadset
or BluetoothA2dp
2.public abstract void onServiceDIsConected(int profile)
profile int
: - One of HEALTH
, HEADSET
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 连接中
公有的方法
abstract List<BluetoothDevice> getConnectedDevices()
Get the current connection state of the profile
Requires BLUETOOTH
permission.
abstratct List<BluetoothDevice> getDevicesMatchingConnectionStates(int[] states)
Get a list of devices that match any of the given connection states.获取目标链接状态的设备列表