Android 中后台作为服务的蓝牙连接?
我正在开发一个应用程序,其中 Android 设备将通过蓝牙连接到设备,并且它们将交换某些数据包。现在,数据包通信应该在后台运行,用户可以在应用程序的屏幕中导航。那么,为此目的,使用作为服务运行的蓝牙通信是否是正确的解决方案?如果没有,那么有人可以让我知道替代方案吗?
我想知道的另一件事是,将服务设置为“远程”并通过 IPC 进行通信是否是一个好主意,或者服务应该与应用程序在同一进程中运行。
I am developing an application in which Android device will be connected to a device via bluetooth and they will be exchanging certain packets. Now, the packet communication should be running in background and user can navigate through the screens of the app. So, for this purpose using bluetooth communication running as service is proper solution or not? If not, then can someone let me know of alternative to it.
One more thing that I wanted to know is whether its a good idea to have the service as "Remote" and communicate over IPC or the Service should be running in the same process as Application.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是的,这是一个非常好的解决方案。事实上,我认为服务组件正是适合这种工作的。如果您不想在手机处于挂起模式时失去连接,请务必检查唤醒锁。
Yes, it's a perfectly good solution. Actually, I think service components are exactly for this kind of work. Be sure to check on wake locks too, if you don't want to lose connection when the phone gets in suspended mode.
是的,这是一个非常好的解决方案。
您需要在 AndroidManifest 文件中定义 Service。
Yes, It is a perfectly good solution.
You need to define Service in AndroidManifest file.