File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Android and the fly likes TCP client in Android phone: run continuously, display image based on message received from server Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Mobile » Android
Bookmark "TCP client in Android phone: run continuously, display image based on message received from server" Watch "TCP client in Android phone: run continuously, display image based on message received from server" New topic
Author

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

Madhu Nandan
Ranch Hand

Joined: Dec 16, 2010
Posts: 52

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

Joined: Oct 12, 2008
Posts: 1369

check for new message every 100 ms

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


[List of FAQs] | [Android FAQ] | [Samuh Varta]
Madhu Nandan
Ranch Hand

Joined: Dec 16, 2010
Posts: 52

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.
 
 
subject: TCP client in Android phone: run continuously, display image based on message received from server
 
Similar Threads
Android: Add custom widget or view (ex. vertical bar) which changes height programmatically
Null pointer exception probably due to synchronisation issues; problem in starting activity
How to pass string from TCP server (a Runnable) to main activity (in Android)?
Android: Cannot show more than one image
Problem in accessing value of global variable