Android Developer -- Bluetooth篇 概述

Posted H_bolin

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Android Developer -- Bluetooth篇 概述相关的知识,希望对你有一定的参考价值。

Bluetooth

  安卓平台支持蓝牙网络协议栈,它允许设备与其他蓝牙设备进行无线交换数据。应用程序框架通过安卓蓝牙APIs提供访问蓝牙功能。这些APIs使应用程序通过无线连接到其他蓝牙设备,使点对点和多点的无线功能。

使用蓝牙APIs,安卓应用程序可以执行以下功能:

  • 扫描其他蓝牙设备
  • 查询本地蓝牙适配器,用于配对蓝牙设备
  • 建立RFCOMM通道
  • 通过发现服务service discovery连接到其他设备
  • 交换数据和其他设备
  • 管理多个连接

The Basics

  这个文档描述了如何使用android Bluetooth APIs去完成四个主要任务去使用Bluetooth交流:安装Bluetooth,查找配对的设备或者在本地可用的设备,连接设备,在设备间交换数据。

所有类都在android.bluetooth这个包,这里是类的一个总览:

BluetoothAdapter

  代表本地蓝牙适配器(蓝牙监听者),BluetoothAdapter是所有使用Bluetooth对话的入口。使用它可以发现其他Bluetooth设备,查找已经配对的设备的列表,初始化一个BluetoothDevice使用一个知道的MAC地址,创建一个BluetoothServerSocket去监听其他设备来进行通信

BluetoothDevice

  代表了远程的Bluetooth设备。远程设备使用它来通过BluetoothSocket发起一个连接或者或者查询设备的名字,地址 ,类名和配对状态

BluetoothSocket

  用来通过InputStream和OutputStream交换数据

BluetoothServerSocket

  用来监听请求,两个设备为了连接,一个设备必须打开一个server socket通过这个类,当远程蓝牙设备发起一个连接来连接这个设备,BluetoothServerSocket会返回一个已经连接的BluetoothSocket当连接接受时

BluetoothClass

  描述蓝牙设备的一般特性和功能。这是一组只读的属性,定义设备的主要和次要设备类及其服务。然而,这并不能可靠地描述设备所支持的所有蓝牙配置文件和服务,但对设备类型的提示是有用的。

BluetoothProfile

  表示蓝牙配置文件的接口。蓝牙配置文件是一种基于蓝牙的设备之间的无线接口规范。一个例子是Hands-Free profile。对于配置文件的更多讨论,see Working with Profiles(看官网的链接)

BluetoothHeadset

  提供了蓝牙耳机支持

BluetoothA2dp

定义如何将高质量的音频通过蓝牙连接从一个设备传输到另一个设备。”A2DP”代表先进的音频分布。

BluetoothProfile.ServiceListener

一个接口,通知bluetoothprofile IPC客户端,当他们已连接或断开了与服务(即内部服务运行一个特定的配置文件)。

 

以上是关于Android Developer -- Bluetooth篇 概述的主要内容,如果未能解决你的问题,请参考以下文章

developer.android.google.cn

Android Make Disappear or remove the blue dot on the map v2

source.android.google && developer.android.google

Android Developer -- Bluetooth篇 开发实例之一

Android Developer导航

Android Developer导航