Reputation: 5419
In my application I receive a data stream via bluetooth. For this purpose I've created a BluetoothService
class which has several threads to communicate with the bluetooth device.
In this class I have also a Thread which receives the data from an InputStream
. The data is received very fast (every 10ms). Receiving of the data stream is working well.
Now I am asking myself how to transport that data to my current activity in order to display (plot) the received data. This should be done in an efficient way. I guess sending broadcasts or somthing like that is too inefficient. Is there some sort of fast event queue or something similar?
How can I send the data from the receiving thread in the service to my activity/fragment?
kind regards
Upvotes: 1
Views: 403
Reputation: 18977
you can use runOnUiThread
or you can use Handler
or you can use AsyncTask
and the progressPublish()
method or you can use post
method of widgets.
Upvotes: 0