android bluetooth简介
来源:互联网 发布:郫县兼职教师招聘知乎 编辑:程序博客网 时间:2024/04/27 13:03
协议设备(接上蓝牙模块的数字传感器),连接流程是:
首先在使用蓝牙的时候必须注册其权限:
<manifest ... > <uses-permission android:name="android.permission.BLUETOOTH" /> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" /> ...</manifest>
1.使用registerReceiver注册BroadcastReceiver来获取蓝牙状态、搜索设备等消息;
2.使用BlueAdatper的搜索;
3.在BroadcastReceiver的onReceive()里取得搜索所得的蓝牙设备信息(如名称,MAC,RSSI);
4.通过设备的MAC地址来建立一个BluetoothDevice对象;
5.由BluetoothDevice衍生出BluetoothSocket,准备SOCKET来读写设备;
6.通过BluetoothSocket的createRfcommSocketToServiceRecord()方法来选择连接的协议/服务,这里用的是SPP(UUID:00001101-0000-1000-8000-00805F9B34FB);
7.Connect之后(如果还没配对则系统自动提示),使用BluetoothSocket的getInputStream()和getOutputStream()来读写蓝牙设备。
具体的可以参见android 官网上的介绍:http://developer.android.com/guide/topics/wireless/bluetooth.html
- android bluetooth简介
- Android Bluetooth简介
- android有关bluetooth常用api简介
- android有关bluetooth常用api简介
- [Bluetooth] Android Bluetooth
- Bluetooth--- android -- 蓝牙 bluetooth
- Android Bluetooth
- Android bluetooth
- Android Bluetooth
- android Bluetooth
- Android Bluetooth
- android bluetooth
- android bluetooth
- Android Bluetooth
- Android Bluetooth
- android bluetooth
- Android Bluetooth
- Android Bluetooth
- From pruned CircleCube Video Player to e-Notice module - Movie Gallery Player
- 全国各地DNS
- WIFI分析与移植
- js验证日期时间格式正则表达式
- Iphone 开发: PLdatabase 数据库应用步骤 (PlausibleDatabase)
- android bluetooth简介
- MSSQL: Arithmetic overflow error converting expression to data type int
- Android WIFI 分析
- struts标签与ActionForm的关系
- JBoss负载均衡两模式配置详解
- 职场进化论--每天淘汰你自己
- 用wpa_cli 连接无线网络
- 移动终端开发配置
- com中的类型对应