android-createRfcommSocketToServiceRecord
2016-07-19 10:31
316 查看
createRfcommSocketToServiceRecord
Added in API level 5BluetoothSocket createRfcommSocketToServiceRecord (UUID uuid)
Create an RFCOMM
BluetoothSocketready to start a secure outgoing connection
to this remote device using SDP lookup of uuid.
This is designed to be used with
listenUsingRfcommWithServiceRecord(String, UUID)for peer-peer Bluetooth applications.
创建一个RFCOMM BluetoothSocket准备好开始一个安全输出连接到远程设备使用SDP查找的uuid。这是设计用于与listenUsingRfcommWithServiceRecord(String,UUID)对等蓝牙应用程序。
Use
connect()to initiate the outgoing connection. This will also
perform an SDP lookup of the given uuid to determine which channel to connect to.使用connect()来初始化输出连接。这也将执行SDP查找给定的uuid,以确定哪些通道连接。
The remote device will be authenticated and communication on this socket will be encrypted.远程设备将认证和通信socket 将被加密。
Use this socket only if an authenticated socket link is possible. Authentication refers to the authentication of the link key to prevent man-in-the-middle type of attacks. For example, for Bluetooth 2.1 devices, if any of the devices does not have an input
and output capability or just has the ability to display a numeric key, a secure socket connection is not possible. In such a case, use {#link createInsecureRfcommSocketToServiceRecord}. For more details, refer to the Security Model section 5.2 (vol 3) of
Bluetooth Core Specification version 2.1 + EDR.使用此socket 只有一个经过验证的socket 的才可能连接。身份验证是指防止中间人的身份验证链接关键类型的攻击。例如,对于蓝牙2.1设备,如果设备没有任何一个输入和输出能力或有能力显示一个数字键,一个安全的套接字连接是不可能的。在这种情况下,使用{
#链接createInsecureRfcommSocketToServiceRecord }。更多细节,请参考5.2节的安全模型(3卷)蓝牙核心规范的版本2.1
+ EDR。
Hint: If you are connecting to a Bluetooth serial board then try using the well-known SPP UUID 00001101-0000-1000-8000-00805F9B34FB.
如果你连接到蓝牙串口板然后试着用通用的SPP UUID 0000 - 0000 - 1000 - 8000 - 1000 - f9b34fb
However if you are connecting to an Android peer then please generate your own unique UUID.
但是如果你是连接到一个Android同行请生成自己的独特的UUID。
Requires
BLUETOOTH
Parameters | |
---|---|
uuid | UUID: service record uuid to lookup RFCOMM channel 服务记录uuid查找RFCOMM通道 |
Returns | |
---|---|
BluetoothSocket | a RFCOMM BluetoothServerSocket ready for an outgoing connectionRFCOMM BluetoothServerSocket准备一个外向连接 |
Throws | |
---|---|
IOException | on error, for example Bluetooth not available, or insufficient permissions产生错误,例如蓝牙不能使用,或权限不足 |
相关文章推荐
- Android中操作Sqlite遇到的错误:java.lang.IllegalStateException: Couldn't read row 1, col 0 from CursorWindow
- Live:主流技术构建即时聊天室演示应用,直播源码
- Android settings中SwitchPreference的简单处理
- Android内存泄漏 ——检测、解决和避免
- android之AlarmManager 全局定时器
- android黑科技——完美解决界面逻辑的数据框架DataBinding(最新)的使用(二)
- Android绘图那些事儿(上)
- 一分钟教会你如何在Android Studio中使用Gradle打包Jar
- Android概览屏幕基础之添加任务和删除任务
- Android Studio若干小问题
- android ExpandableListView三级菜单的使用
- android 的自我学习
- Android学习笔记031之Fragment
- android.content.res.Resources$NotFoundException: Unable to find resource ID 0#0xffffffff
- Android自定义View的实现方法,带你一步步深入了解View(四)
- Android视图状态及重绘流程分析,带你一步步深入了解View(三)
- 透明色的16进制
- Android视图绘制流程完全解析,带你一步步深入了解View(二)
- android 实现Activity的右滑返回效果
- AndroidTextView在xml初始化的问题