永发信息网

在Android的蓝牙4.0 API的close和断开之间的区别

答案:2  悬赏:20  手机版
解决时间 2021-03-21 18:56
在Android的蓝牙4.0 API的close和断开之间的区别
最佳答案
通过断开连接()您可以稍后致电连接()并继续这一循环。

在你调用关闭()你做。如果你想再次连接,你将不得不调用 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持有的任何资源。 ‍
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
考驾照除了交学费之外还得交其他什么钱吗,不
国内 手机 为什么没有google
送给小学生的励志名言,小学生励志名言名句
在日常生活和生产中,我们会接触到很多物质,
酒后好几天举报酒驾有视频还管用吗
2000年9月25日出生,女,周玉婷
男友和我相处后还在网上相亲 我怎么办
电脑最多能登几个微信,一台电脑怎么同时登录
判断题地表沟壑纵横,水土流失严重的高原是云
金莎地产在什么地方啊,我要过去处理事情
1980年11月23日子时出生的五行
今天去医院,检查,医生喊我明天上午再去验血
室内空调怎么拆开清洗,美的空调如何拆洗
锋字多少笔画啊
相亲对象突然不让我浏览她的朋友圈
推荐资讯
爱国的诗句小学,描写人嘴巴大的句子 急用!&#
3dmax导出带动画的FBX文件放入u3d中人物全乱
梅雨都是什么地方有?华北有吗
眼睛的分类,比如什么桃花眼、杏眼、丹凤眼都
福田奥铃txc1能驾驶吗
美日新汽车美容中心地址在什么地方,想过去办
南航和南理哪个更好?
中位数:将一组数据_____处在______的一个数据
如何让学生在轻松愉快的氛围中学习知识
我让个坐居然还罚钱,真的没办法
请问专家纤维肉瘤复发的几率大么?
单选题美蒋发动全面内战开始于A.1945年8月B.1
正方形一边上任一点到这个正方形两条对角线的
阴历怎么看 ?