是否存在用于通过Android中的蓝牙进行通信的本机API?如果在哪里可以找到本文档? [英] Are there native APIs for communication over Bluetooth in Android?if so where do i find the documentaion?

查看:110
本文介绍了是否存在用于通过Android中的蓝牙进行通信的本机API?如果在哪里可以找到本文档?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个C ++库,该库有助于通过LAN和串行端口与POS终端建立通信,现在我希望该库只能在蓝牙媒体上的android手机上工作,

I have a C++ library which helps in establishing communication to a POS terminal over LAN and serial port, now i want this library to work on android phone only over Bluetooth medium,

如果android中存在用于蓝牙通信的本机API,我可以将此c ++库移植到android并编写一个Java应用程序,它将通过JNI使用该库

If there are native APIs for Bluetooth communication in android, I can port this c++ library to android and write a java application which will use this library through JNI

Android中是否有用于蓝牙的本地API,如果可以的话,我在哪里可以找到文档?

Are there native APIs for Bluetooth in android, if so where do I find the documentation?

推荐答案

不久前,我研究了这个一般性问题(java与Android上的本机蓝牙),最终得出的结论是,本机API相对于本机没有提供任何额外的功能. Java API-因此,原生使用蓝牙对我来说没有任何优势.

I looked at this general issue (java vs. native Bluetooth on Android) a while ago and eventually concluded that the native API did not provide any extra functionality relative to the Java API - so there was no advantage for me in going native for Bluetooth.

与您可能期望从中得到的结果相比,有据可查的Java Bluetooth API实际上非常有限.台式机Linux,Mac或Windows.您距离HCI数英里.关键是,您可能会发现您的库所需的API在Android上不可用(除非它只需要比RFCOMM套接字更多的东西).

And the Java Bluetooth API, which is well documented, is actually quite limited compared to what you might expect coming from e.g. desktop Linux, Mac, or Windows. You are miles away from the HCI. The point being, that you may well find that the API's required by your library are not available on Android (unless it requires little more then RFCOMM sockets).

如果Android Bluetooth API确实满足您的库的要求,那么可以,您可以从本机代码访问它们,从而可以移植您的库.

If the Android Bluetooth API's do meet the requirements of your library, then yes, you can access them from native code so you could port your library.

注意事项:当我看到此内容时,我强烈建议开发人员不要使用本机,因此我没有在Android上做过任何本机,而只是反映了我所读的内容.

Caveat: when I looked at this I saw that devs are strongly advised away from native, so I have not done any native on Android and am only reflecting what I read.

这篇关于是否存在用于通过Android中的蓝牙进行通信的本机API?如果在哪里可以找到本文档?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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