Very helpful, thank you!  That is a good idea for the pre and post
fix.

I am a little confused then on how to implement my handler then.  I
want to receive the input and then display it right away.  So is it
because I have a constant stream of numbers coming in the CommThread
doesn't ever stop its thread and can't send it to the UI handler?
What is the best way to do that?  Should I limit the stream of numbers
that comes in (say for example when it sees the last value of the
"^37$")?  Or is there a better way to call the handler to display the
number on the screen?

I suppose I am a little confused on what handlers actually do and how
to use them...I am in the process of learning all of this.



On Apr 23, 4:03 pm, spachner <[email protected]> wrote:
> Hi,
>
> 1) "As your wrote "a bluetooth device that is sending the temperature
> to the android phone in a constant _stream_", so not expect that the
> characters are coming somehow synced. Depending on internal socket
> stuff sometimes just a single char is received, sometimes more at
> once. The receiver is responsible to collect the read chars and do the
> sematic, i.e. the interpretation of the data by yourself. I would
> recommend to pack the data at the sender with chars which allows the
> receiver to pick the payload in between easily. E.g. when you want to
> transport temperature values the payload in something out of these
> chars "0123456789.". Then you could put a prefix (e.g. "^") and a
> postfix (e.g. "$") which would result in "^38$". The delimiting
> characters actually do not matter just use which is guaranteed not in
> the payload. The receiver then just collects the strings received and
> post process which is simply searching for the prefix and the postfix.
> Wait until both are in the collected string, then remove them and the
> chars in between is your payload, your temperature value.
>
> 2) Seems that the handler mHandler is one from the thread the read()
> is done and not from thread the actvitiy runs in as you want. If so
> the handleMessage() could only be executed when the thread is not
> blocked anymore what happens when the while(true) loop is broken by
> the exception.
>
> Hope I am right and it helps!
>
> regards
>
> spachner
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group 
> athttp://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to