0

hi mate i have in android two thread plus the main thread. the first thread called A, examine the configuration of some view in the current fragment and send request to the second thread called B that have a channel blutooth toward a serial device. the thread B reads value via bluetooth and send response to thread A. when thread a receive response, send the response to main thread that set values of response in the view of main thread and send other request to thread A . But how can use for comunication between thread ?

esoni
  • 1,362
  • 4
  • 24
  • 37

2 Answers2

1

You could use a Handler if you make sure your thread has a Looper : http://developer.android.com/reference/android/os/Handler.html

Xval
  • 938
  • 5
  • 17
  • A Looper allows you to create a loop in your thread, e.g. your thread will be able to receive message and process them, for more informations, take a look at : http://developer.android.com/reference/android/os/Looper.html – Xval Sep 04 '12 at 13:10
0

Why not have a look at a simpler solution:

LocalBroadcastManager (with the penalty of adding the android support library to your application). It will save you time in development and maintenance of the code.

Don't forget to vote up/correct!

Community
  • 1
  • 1
Radu
  • 2,076
  • 2
  • 20
  • 40