Android的编程蓝牙配对蓝牙、Android

由网友(人生如戏ゞ全靠演技)分享简介:我想以编程方式配对我的手机使用蓝牙接口医疗传感器。我的地址和必要的密码,用于连接到设备,但我想,以避免用户交互(配对过程 - 传感器配置等)I would like to programmatically pair my mobile phone with medical sensor using Bluetooth...

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

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,所以我用反射来调用该方法根据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.

阅读全文

相关推荐

最新文章