Reputation: 405
Basically what I have done is taken source code from two different projects and cobbled it together to try to create a new application that plots Bluetooth data in real-time. The intermediate result is apparently more complicated than I am able to comprehend. I have asked questions, gotten feedback, done a lot of reading, but I am still stuck with what I see as the problem: How do I get data from a data acquisition thread into a plotting activity in real-time? This question requires some explanation.
I started with the source code from Blueterm, a Bluetooth terminal emulation program which supports SPP/RfComm. First step was to build and run Blueterm on my Android phone and get it to connect and communicate with an external Bluetooth data acquisition device. This went well - device data scrolls across the screen nicely.
Next I went to AndroidPlot and got the source code for OrientationSensorExample, and I added that to my project so that I could start this activity from the Options Menu. This went well also. My application starts the Orientation Sensor activity which plots Orientation Sensor data in real-time while continuing to acquire data from the Bluetooth device in the background also in real-time.
What I want to do now is modify my application so that the Orientation Sensor activity plots the Bluetooth data (not the Orientation Sensor data) in real-time. Using logcat I know for a fact that the Orientation Sensor activity is plotting orientation sensor data in real-time and continuing to acquire Bluetooth data in the background in real-time.
This suggests an architecture: While my application is plotting orientation sensor data in real-time there is a background thread that is continuing to acquire Bluetooth data in real-time. Or another way of looking at it: There was a Bluetooth activity that spawned/generated/created/whatever a background thread (or just a thread) that continues to run even after I have started the Orientation Sensor activity (all of this observed through logcat).
So the question remains: How do I pass data from this background thread (that was started by a Bluetooth activity) into the Orientation Sensor activity?
Upvotes: 3
Views: 1949
Reputation: 10632
you can make your data as static or you can use Application class of Android framework. So that your background thread keep updating the static data and you will retrieve that updated data in your Activity.
Upvotes: 3