【最新API翻译】 Bluetooth--BluetoothAdapter API 翻译

最近学习Bluetooth通讯的问题,看了几篇文章,再看API的时候更加觉得API才是王道,因此尝试自己翻译一下,借此学习理解。

英文原文:
class overview:
Represents the local device Bluetooth adapter. The BluetoothAdapter lets you perform fundamental Bluetooth tasks, such as initiate device discovery, query a list of bonded (paired) devices, instantiate a BluetoothDevice using a known MAC address, and create a BluetoothServerSocket to listen for connection requests from other devices, and start a scan for Bluetooth LE devices.

To get a BluetoothAdapter representing the local Bluetooth adapter, when running on JELLY_BEAN_MR1 and below, call the static getDefaultAdapter() method; when running on JELLY_BEAN_MR2 and higher, retrieve it through getSystemService(String) with BLUETOOTH_SERVICE. Fundamentally, this is your starting point for all Bluetooth actions. Once you have the local adapter, you can get a set of BluetoothDevice objects representing all paired devices with getBondedDevices(); start device discovery with startDiscovery(); or create a BluetoothServerSocket to listen for incoming connection requests with listenUsingRfcommWithServiceRecord(String, UUID); or start a scan for Bluetooth LE devices with startLeScan(LeScanCallback).Note: Most methods require the BLUETOOTH permission and some also require the BLUETOOTH_ADMIN permission.

中文翻译:

类概述:
BluetoothAdapter表示本地设备的蓝牙适配器。你可以利用BluetoothAdapter执行基本的蓝牙操作,比如发起蓝牙设备搜索,查询手机已连接(或配对)的设备列表,通过已知的MAC地址初始化一个蓝牙设备,以及生成一个BluetoothServerSocket类来监听其它设备的连接请求或者发起对其它蓝牙设备的搜索(Bluetooth LE 即 Bluetooth low energy)。

要获取到代表本机蓝牙适配器的BluetoothAdapter,在JELLY_BEAN_MR1(4.2)或者更低版本设备上,可以调用静态方法getDefaultAdapter();在JELLY_BEAN_MR2(4.3)及高版本上,调用getSystemService(String)并结合字符串常量BLUETOOTH_SERVICE。一般来说,操作蓝牙设备前都要先获取BluetoothAdapter。

一旦获取了本地的适配器,就可以通过
调用getBondedDevices()获取已配对设备集合;调用startDiscovery()开始蓝牙设备搜索;
调用 listenUsingRfcommWithServiceRecord(String, UUID)产生一个BluetoothServerSocket来监听连接请求;
调用startLeScan(LeScanCallback)扫描BLE设备。

注意:大部分的方法要求获得“BLUETOOTH”权限,一些也需要获得“BLUETOOTH_ADMIN”权限。

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值