如何共享蓝牙在一个应用程序收到多个活动之间的数据 [英] How to share Bluetooth received data among multiple activities in one application

查看:216
本文介绍了如何共享蓝牙在一个应用程序收到多个活动之间的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个有5个不同的选项卡的应用程序,现在我有蓝牙连接在我的第一个选项卡的活动。此活动接收从其他设备和显示数据。但是,这方面是不是在同一个应用程序中的其他选项卡活动有帮助的。

I have an application which has 5 different tabs, Now i have Bluetooth connectivity in my first tab activity. This activity receives data from other device and display. But this connection is not helpful for the other tabs activity in the same application.

我想你的建议如何实现蓝牙连接在同一个application.So,我可以从其他设备中的所有相应的predefined活动接收数据并显示该信息的活动。

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.

请在此发表评论。

做u认为这可以通过在后台运行并且接收到的数据推到活性的服务来实现。?如果是的话怎么样?

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进行沟通,
ü可以尝试改变聊天处理程序,并在活动的变化,它会在前面味精发送到前所未有的活动。

I followed this(http://developer.android.com/guide/topics/connectivity/bluetooth.html) link to make bluetooth connections and a class named ConnectedThreads requires some handler to communicate with UI, U can try changing chat handler as and when activity changes and it will send msg to which ever activity in front.

这篇关于如何共享蓝牙在一个应用程序收到多个活动之间的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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