android 蓝牙sdk封装,Android 蓝牙SDK 使用文档.PDF

Android 蓝牙SDK 使用文档

Android 蓝牙SDK 使用文档

目录

1. 导入SDK 2

2. 基本配置 2

3. 初始化 2

3.1. 通过初始化获取到蓝牙的服务: 2

3.2. 注册Android 广播 2

4. 操作 5

4.1. 搜索 5

4.2. 停止搜索 5

4.3. 发送命令 5

4.4. 连接设备 6

4.5. 断开连接 6

4.6. 关闭蓝牙服务 6

附录一:3rdSDK id 列表 6

附录二 更新履历 7

1

1. 导入SDK

将下载包中的libs 文件夹合并到本地工程libs 子目录下;在Eclipse 中右键

工程根目录,选择Properties -> Java Build Path -> Libraries,然后点击Add

External JARs... 选择指向jar 的路径,点击OK,即导入成功。 (ADT17 及以上

不需要手动导入)

2. 基本配置

配置manifast :

配置 service (康诺云):

android:name= "com.chronocloud.ryfibluetoothlibrary.service.BluetoothServic

e" android:enabled= "true" />

3. 初始化

3.1. 通过初始化获取到蓝牙的服务:

try {

BluetoothService mBluetoothService = BluetoothFactory.getInstance()

.initBluetooth(mThirdSdkID,

getApplicationContext());

} catch (BluetoothException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

参数 释义

mThirdSdkID 第三方sdk的唯一标示,见附录一。

getApplicationContext() 全局上下文对象

3.2. 注册Android 广播

动态注册:

IntentFilter filter = new IntentFilter();

//设备上报

2

filter.addAction(BluetoothMessage.ACTION_ON_DEVICE_FOUND);

//报警上报

filter.addAction(BluetoothMessage.ACTION_ON_ALARM_REPORTED);

//属性上报

filter.addAction(BluetoothMessage.ACTION_ON_ATTR_CHANGED);

//连接状态上报

filter.addAction(BluetoothMessage.ACTION_ON_CONNECT_CHANGED);

//连接异常上报

filter.addAction

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值