Android:如何通过蓝牙浏览远程设备文件系统?
我需要构建一个 Android 应用程序,通过蓝牙从远程设备放置/获取文件;应用程序还必须浏览远程文件系统。 我读过一些有关 OBEX 的内容,但除了市场上一些出色的应用程序(例如蓝牙文件传输)之外,还没有找到任何适用于 Android 的示例。 如何在应用程序中实现它?
I need to build an Android app that puts/gets files from a remote device via Bluetooth; the app must also browse the remote filesystem.
I've read something about OBEX but have really not found any example for Android, except some great apps on the market as Bluetooth File Transfer.
How can it be implemented in an app?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
由于 Android 上的开发人员没有公开 OBEX OPP/FTP 的标准方法/实现,因此您必须自行解决 蓝牙 API 功能强大,几乎可以实现您想要的任何协议,因为它镜像 TCP 套接字。
您要做的第一件事是访问文件系统。假设使用 SD 卡,这里 是一个指南,否则你需要 root 访问权限。然后您希望在两个设备之间建立蓝牙连接(样板代码)。最后,您应该通过 Google 搜索 OBEX OPP/FTP 的协议规范并实施它,这可能会花费最多的时间。
我很确定市场上的其他应用程序就是这样做的,因为它们需要两个设备上的应用程序才能发送/接收文件并浏览文件系统。我无法深入了解 OBEX 协议本身,因为我不熟悉它,但如果需要的话我可以详细说明之前的所有内容。然而,谷歌搜索发现了这个,这在实现时可能很有用。
不确定这是否有帮助,但我已经看到这个 曾为很多人发送过文件。
Since there is no standard method/implementation of OBEX OPP/FTP that is exposed to developers on Android, you will have to roll you own over the Bluetooth API which is powerful enough implement just about any protocol you want as it mirrors TCP sockets.
The first thing you will have to do is get access to the filesystem. Assuming the SD Card, here is a guide otherwise you would need root access. Then you want to get a Bluetooth connection working between two devices (boilerplate code). Lastly you should Google up the protocol specification for OBEX OPP/FTP and implement it which is probably going to take the most time.
I'm pretty sure that's how the other apps on the marketplace do it as they require the app on both devices in order to send/receive files and browse the filesystem. I can't go in depth on the OBEX protocol itself as I'm not familiar with it but I can elaborate on everything before that if needed. However a google search turned up this which may be useful while implementing.
Not sure if this will help but I've seen this to have worked for a lot of people to send files.
这是内置 Android API 无法实现的。您可以调用一些意图来通过蓝牙共享文件 - 但模型之间的兼容性有所不同。但是,如果您想为已root的手机编写应用程序,可以使用一些方法。如果是这种情况,请注意。
This is not possible with the built-in Android API. There are intents you can call to share files over Bluetooth - but compatibility between models varies. However, there are some methods if you would like to write an app for rooted phones. If this is the case, please note it.