在Android的蓝牙4.0 API的close和断开之间的区别
答案:2 悬赏:20 手机版
解决时间 2021-03-21 18:56
- 提问者网友:遮云壑
- 2021-03-21 07:22
在Android的蓝牙4.0 API的close和断开之间的区别
最佳答案
- 五星知识达人网友:鱼忧
- 2021-03-21 07:48
通过断开连接()您可以稍后致电连接()并继续这一循环。
在你调用关闭()你做。如果你想再次连接,你将不得不调用 connectGatt()在 BluetoothDevice类试; 关闭()将释放由 BluetoothGatt持有的任何资源。
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 连接中
int
STATE_DISCONNECTED
int
STATE_DISCONNECTING
公有的方法
abstract List
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 getDevicesMatchingConnectionStates(int[] states)
Get
a list of devices that match any of the given connection states.获取目标链接状态的设备列表
在你调用关闭()你做。如果你想再次连接,你将不得不调用 connectGatt()在 BluetoothDevice类试; 关闭()将释放由 BluetoothGatt持有的任何资源。
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 连接中
int
STATE_DISCONNECTED
int
STATE_DISCONNECTING
公有的方法
abstract List
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
Get
a list of devices that match any of the given connection states.获取目标链接状态的设备列表
全部回答
- 1楼网友:枭雄戏美人
- 2021-03-21 08:33
通过断开连接()您可以稍后致电连接()并继续这一循环。
在你调用关闭()你做。如果你想再次连接,你将不得不调用 connectgatt()在 bluetoothdevice类试; 关闭()将释放由 bluetoothgatt持有的任何资源。
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯