• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

TCP client in Android phone: run continuously, display image based on message received from server

 
Madhu Nandan
Ranch Hand
Posts: 52
Android Eclipse IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

Firstly, I have been greatly helped by this forum. Now my problem this time.

I have a TCP client running in Android phone. It connects and receives data from a windows application. Once I receive a message, I parse it and I try to display an image. I have to keep checking for new messages from this windows app.

The client thread keeps running. When a message is received, I pass it to the main activity, parse it but I am not able to display the image. I want to make the client check for new message every 100 ms. At the moment, the LogCat gets flooded as the thread keeps running and I am not able to really see the contents of LogCat.

Basically I want to run the client, keep checking for new messages every 100 ms, when a new message is there, pass it to the main activity, parse it and display an image. Please go through the code below and suggest any corrections or a better approach if necessary.

Cheers,
Madhu

The client code is below.

Main activity:



Interface:



Client thread:

 
Monu Tripathi
Rancher
Posts: 1369
1
Android Eclipse IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
check for new message every 100 ms

You might want to increase the polling interval for one thing.
 
Madhu Nandan
Ranch Hand
Posts: 52
Android Eclipse IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Monu Tripathi wrote:
check for new message every 100 ms

You might want to increase the polling interval for one thing.


Thank you for the response. Could you suggest how to increase the polling interval? I can think of TimerTask. But I am not sure where to use this TimerTask in the client thread.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic