开发者

How can an Android background thread detect if another activity is active and ready to receive data? [closed]

开发者 https://www.devze.com 2023-03-10 08:32 出处:网络
This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time,or an extraordinarily narrow situation that is not generally applic
This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 11 years ago.

Background: I'm using Eclipse to develop an Android application that plots Bluetooth data on a Android phone in real-time. It consists primarily of a Bluetooth Activity, a background thread created by the Bluetooth Activity, and a Plotting Activity.

The primary focus of my question: Is there a mechanism for the Bluetooth background thread to detect if the Plotting Activity is active and ready to somehow receive the Blueto开发者_StackOverflow社区othData? Or better, can the background thread be listening for some event that tells it the Plotting Activity is active?

This is open source code that I am hacking on. With Logcat I have deduced that the Bluetooth Activity must have created some sort of background thread that continues to produce new BluetoothData even when I switch to my Plotting Activity.

Eventually, I found the method in the background thread that writes the BluetoothData to Logcat. So I feel I should be able to leverage this method to somehow "stream", as it where, the BluetoothData to the Plotting Activity or something if only it could determine the Plotting Activity is active.

So that's my question. But maybe I am going in the wrong direction? Maybe I just somehow send the thread's data and check some result code to see if it worked. If so, I'm in business. Otherwise the other activity was not active. I don't really like this approach, because I would be polling to see if the other activity was active.

Any suggestions?


this question is answered based on the comments.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号