I ask the help of knowledgeable people to send on the right path. There is a task to transmit and receive some data via bluetooth with android. with this, in fact, no problems. Based on many examples (the main, this is the messenger), the main activit made a stream for receiving and transmitting messages, followed by processing in the handler. There was a need to send, and ideally, and receive data via bluetooth from other activity that is different from the main one. Actually the question is whether it is possible to transfer / receive data into a stream / from the main activity stream to / from another activity. The variant with Intent for result is not suitable, if only because it requires closing the activity.

until, basing on a small experience, the thought is ripe, to make the next “crutch”. when switching to another activity, stop the flow, break the socket (if there was a connection), and in the new activity all over again, new flow, new handler, etc., almost the same as in the main activity but with a slightly different data set to send / receive. (the commands are simple, depending on the contents of the fields, checkboxes, etc., a byte array is formed, which is sent / received)

Is there a way to do this more intelligently and accurately. Please also take into account that I started writing under android quite recently, therefore there is very little experience and knowledge, but I am capable of learning. I ask only to indicate the direction in which to "dig."

  • Apply the observer pattern. - Leonid
  • It seems that this is what is needed, I will understand .. thanks a lot. I will write about the result. - Adler

0