Android 蓝牙
来源:互联网 发布:淘宝店铺上传宝贝软件 编辑:程序博客网 时间:2024/05/01 12:29
参考文章:http://wear.techbrood.com/guide/topics/connectivity/bluetooth.html ,这是developer.android.com在中国的一个镜像,大家可以收藏。
蓝牙连接初识
下图是对Android蓝牙连接的一个通俗的认识,有雷同,实属巧合。
主要有下面几个步骤:
一、Setting Up Bluetooth
- 验证设备是否支持蓝牙
- 打开蓝牙
二、查找设备
- 请求已配对的设备
- 加入没有请求到,则发现新的设备
三、连接设备
- 作为client连接设备
- 作为server连接设备
四、管理连接
- 写数据(写数据到设备上)
- 读数据(从设备读取数据)
心得体会
- 发现新朋友是需要耗费很多资源,一旦发现了设备,在连接设备之前需要取消发现,否则会占用带宽 。
- 安卓也提供了专门用于连接健康可穿戴设备的profile,即Health Device Profile (HDP),用于封装和简化蓝牙连接。
这是步骤:
Creating an HDP Application
Here are the basic steps involved in creating an Android HDP application:
Get a reference to the BluetoothHealth proxy object.
Similar to regular headset and A2DP profile devices, you must call getProfileProxy() with a BluetoothProfile.ServiceListener and the HEALTH profile type to establish a connection with the profile proxy object.
Create a BluetoothHealthCallback and register an application configuration (BluetoothHealthAppConfiguration) that acts as a health sink.
Establish a connection to a health device. Some devices will initiate the connection. It is unnecessary to carry out this step for those devices.
When connected successfully to a health device, read/write to the health device using the file descriptor.
The received data needs to be interpreted using a health manager which implements the IEEE 11073-xxxxx specifications.
When done, close the health channel and unregister the application. The channel also closes when there is extended inactivity.
- android 蓝牙
- Android 蓝牙
- android 蓝牙
- Android蓝牙
- Android 蓝牙
- Android 蓝牙
- Android蓝牙
- Android蓝牙
- Android 蓝牙
- Android蓝牙
- android-蓝牙
- Android 蓝牙
- Android-蓝牙
- Android 蓝牙
- Android蓝牙
- android 蓝牙
- Android 蓝牙
- android 蓝牙
- 如何通过V社官方API查找比赛记录
- XUtils使用
- 快速排序
- set中的set_union用法
- Redis添加访问密码
- Android 蓝牙
- Java内存模型FAQ(三)JSR133是什么?
- Android---破解锁屏密码、获取wi-fi密码
- Weka数据挖掘——分类
- websphere停止服务:此日期在当前日期/时间之后有效。如果客户机的时钟设置得比服务器的时钟早,就会出现这种情况。请验证此客户机与服务器的时钟是否同步,然后重试该请求。
- 浅谈 Java 多线程环境下 如何跟踪死锁 (例子)
- LVDS接口分类,时序,输出格式
- Objective-C的hook方案(一): Method Swizzling
- 关于DOTA2排名前5战队惯用英雄分析