Android的编程蓝牙配对 [英] Android Programmatically Bluetooth Pairing

查看:159
本文介绍了Android的编程蓝牙配对的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想以编程方式配对我的手机使用蓝牙接口医疗传感器。我的地址和必要的密码,用于连接到设备,但我想,以避免用户交互(配对过程 - 传感器配置等)

I would like to programmatically pair my mobile phone with medical sensor using Bluetooth interface. I have address and PIN necessary for connecting to device but I would like to avoid user interaction (pairing process - sensor configuration etc.)

我尝试使用非官方的蓝牙API(HTTP://$c$c.google.com/p/android-bluetooth/),但似乎这并不适用于Android 2.1及以上(我LocalBluetoothDevice八方通空,人们在他们的论坛上表示,这只是针对1.X版本)

I tried using unofficial Bluetooth API (http://code.google.com/p/android-bluetooth/) but it seems that this doesn't for Android 2.1 and above (I got LocalBluetoothDevice allways NULL, and people on their forum said that this is only for 1.X versions)

我看到了Android的API有一个做到这一点的配对在后台方法,但它们都标有@hide注释。如何访问呢?

I saw that Android API has methods that do this pairing in background but they are labeled with @hide annotation. How do I access this?

没有人也成功地在此? (配对编程)任何例子吗?

Did anyone succeeded in this? (programmatically pairing) Any example?

谢谢!

推荐答案

我认为你需要使用 createInsecureRfcommSocketToServiceRecord()这是API 10介绍我有得到这个工作在Android 2.2,所以我用反射来调用该方法根据<一个href="http://stackoverflow.com/questions/5308373/how-to-create-insecure-rfcomm-socket-in-android/5319114#5319114">this方法和放大器;有效。我识别蓝牙设备我连接到它的好记的名称和放大器;将它设置为不要求密码键,我的Andr​​oid应用程序现在连接到它没有设备无需粘合或任何密码输入,所以它的安全问题。

I think you need to use createInsecureRfcommSocketToServiceRecord() which is introduced in API 10. I've got to get this working on Android 2.2, so I used reflection to call the method as per this method & it worked. I am identifying the Bluetooth device I connect to by its friendly name & setting it to not require PIN bonding, my Android APP now connects to it without the device having to be bonded or any PIN input, so its a security concern.

这篇关于Android的编程蓝牙配对的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆