Android Question Please help with image view problem

tman

Member
Licensed User
Longtime User
I have one small problem left in my app before it is complete. My app creates a UDP socket and sends a hex string every 1.6 seconds and listens for a reply. When a packet is recieved (it is 15 bytes in length) I am only interested in the 8th byte. The 8th byte is converted to an interger and then places a bitmap image on the screen according to the integer recieved. I used the designer to add the imageview to the screen. The bitmap images are small at 1.4k each. The app almost does what I want. The proper image appears breifly on the screen before reverting back to "image0.png" I want the image to stay on the screen until the next timer tick when the image is updated by a new packet received.
I would greatly appreciate any help.
 
Last edited:

tman

Member
Licensed User
Longtime User
If I understand correctly you want to ignore packets that arrive after the first one. You can use a global variable. Set it to True in Timer1_Tick and then in UDP_PacketArrived check whether it is true and set the bitmap. Then set it to false.

Erel,
Thank you for responding to my post BFA is a wonderful program and I love it! Thank you for helping me. You didn't understand my question I don't have a background in computer programming so I might be missing something simple. I will try to redefine my problem more clearly. Again many thanks for your help. The packets arrive every 1.6 seconds and contain 15 bytes of data. I only need the 8th byte - and show it on the screen as an image. So every time a packet arrives I extract the 8th byte and load an image to the screen based on the int value of the byte. My app coding actually does this - however, the image loads onto the screen then quickly reverts back to the default image "image0.png" So the user sees the new image as a "flicker." If the 8th bytes value is a "5" I see "image5" on screen only to be quickly replaced by "image0" - note: "image0" is properly shown if the 8th byte happens to be a "0".
 
Last edited:
Upvote 0

tman

Member
Licensed User
Longtime User
The question is why image0 is displayed after you set a different image.

My guess is that UDP_PacketArrived is raised another time with different data. Use Log keyword to see when this event is raised.
Erel,
I fixed the problem by closing the socket each time a packet arrived.
So the sequence is:
  • packet arrived
  • close socket
  • read data and display image
  • initialize socket (turn it back on)
Thanks again Erel! I am happy my app works!
 
Upvote 0
Top