对于Android 的英文帮助文档,总是看了记不住,远不如对中文资料那么印象深,所以下面的叙述都是对Android 帮助文档Bluetooth 的翻译。 一、Bluetooth Android 平台包含了对Bluetooth 协议栈的支持,允许机器通过 Bluetooth 设备进行无线数据交换。应用框架通过 Android Bluetooth API 访问 Bluetooth 功能模块。 这些 API 能让应用无线连接其他 Bluetooth 设备,实现点对点和多点之间的通信。 运用蓝牙 API,Android 应用程序可以完成如下操作: 1、扫描其他 Bluetooth 设备。 2、查询配对Bluetooth 设备的本地 Bluetooth 适配器。 3、建立 RFCOMM 通道。 4、通过服务探索连接到其他设备。 5、与其他设备进行数据传输。 6、管理多个连接 二、The Basics 本文描述如何使用 Android Bluetooth APIs 完成 Bluetooth 通讯的4 个必要任务:设置Bluetooth,搜寻本地配对或者可用的Bluetooth 设备,连接 Bluetooth 设备,与 Bluetooth设备进行数据传输。 所有可用的Bluetooth APIs 都包含在 android.bluetooth 包中。下面是建立 Bluetooth 连接需要用到的类和接口的总结: 1、BluetoothAdapter 描述本地 Bluetooth 适配器(Bluetooth 接收器)。BluetoothAdapter 是所有 Bluetooth 相关活动的入口。运用 BluetoothAdapter 可以发现其他 Bluetooth 设备,查询连接(或配对)的设备列表,用已知 MAC 地址实例化一个 BluetoothDevice 对象,创建一个BluetoothServerSocket 对象侦听其他设备的通信。 2、BluetoothDevice 描述一个远程 Bluetooth 设备。可以用它通过一个 BluetoothSocket 请求一个远程设备的连接,或者查询远程设备的名称、地址、类、连接状态等信息。 3、BluetoothSocket 描述一个 Bluetooth Socket 接口(类似于TCP Socket)。应用通过 InputStream 和OutputStream.与另外一个 Bluetooth 设备交换数据,即它是应用与另外一个设备交换数据的连接点。 4、BluetoothServerSocket 描述一个开放的 socket 服务器,用来侦听连接进来的请求(类似于 RCP ServerSocket)。为了连接两个 Android 设备,一个设备必须使用该类来开启一个 socket 做服务器,当另外一个设备对它发起连接请求时并且请求被接受时,BluetoothServerSocket 会返回一个连接的 BluetoothSocket 对象。 5、BluetoothClass 描述一个 Bluetooth 设备的一般规格和功能...