简体   繁体   English

如何在一个应用程序中的多个活动之间共享蓝牙接收的数据

[英]How to share Bluetooth received data among multiple activities in one application

I have an application which has 5 different tabs, Now i have Bluetooth connectivity in my first tab activity. 我有一个具有5个不同选项卡的应用程序,现在我的第一个选项卡活动中具有蓝牙连接。 This activity receives data from other device and display. 此活动从其他设备接收数据并显示。 But this connection is not helpful for the other tabs activity in the same application. 但是此连接对同一应用程序中的其他选项卡活动没有帮助。

I want your suggestion how to achieve Bluetooth connectivity for all the activities in the same application.So that i can receive data from other device and display that information in all the respective predefined activities. 我想要您的建议,如何为同一应用程序中的所有活动实现蓝牙连接。这样我就可以从其他设备接收数据并在所有相应的预定义活动中显示该信息。

Please comment on this. 请对此发表评论。

do u think this can be achieved by a service running in background and pushing the received data to the activity.? 您是否认为可以通过后台运行的服务并将接收到的数据推送到活动中来实现? If yes then How? 如果是,那怎么办?

Or if you have any other suggestion then please share them asap. 或者,如果您有其他建议,请尽快分享。

我遵循了此链接( http://developer.android.com/guide/topics/connectivity/bluetooth.html )进行蓝牙连接,名为ConnectedThreads的类需要一些处理程序与UI进行通信,U可以尝试将聊天处理程序更改为当活动发生变化时,它将向前面的活动发送味精。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM