aspose file tools*
The moose likes Android and the fly likes Android: Cannot show more than one image Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Mobile » Android
Bookmark "Android: Cannot show more than one image" Watch "Android: Cannot show more than one image" New topic
Author

Android: Cannot show more than one image

Madhu Nandan
Ranch Hand

Joined: Dec 16, 2010
Posts: 52

Hello,

I have the following main class and thread-TCP Client. The client runs in a loop, receives messages and passes it to main class. In the main class, I parse the message and try to show different images based on the name and value of the message received. Ex: shiftDirection1 name: shiftDirection & value: 1

But I can show only the image corresponding to the first received message and the images corresponding to the remaining received messages cannot be displayed.

Please go through the code below and kindly suggest the mistake/problem and alternative ways.

Thank you for your time and efforts.

Madhu

main class:



Only the image corresponding to the first if case is displayed. The program control enters the second if loop but does not show the image there.

Interface:



Thread (TCP Client):

Daniel Trebbien
Ranch Hand

Joined: Jul 10, 2007
Posts: 57
Does actionOnData ever get called a second time?
Madhu Nandan
Ranch Hand

Joined: Dec 16, 2010
Posts: 52

Daniel Trebbien wrote:Does actionOnData ever get called a second time?


Of course... Every time there is a new message read in the client (thread), it is passed to the parser and after parsing, the actionOnData is called from the parser.
Daniel Trebbien
Ranch Hand

Joined: Jul 10, 2007
Posts: 57
I think that the problem is that the calls to actionOnData are not executing on the UI Thread.

Bear with me...

One thing that you can do to make the programming cleaner is to switch to using a pull parser to parse the messages that are generated by the service running at 192.168.62.23:1200.

Currently you expect data from the service to be:



This is rather brittle. What if your service responded with a true XML document:



You can parse this with a streaming XML parser:



Now, the TcpHandler class is implemented as follows:



And TcpListener is:



Your TcpListen activity becomes:



Then get rid of the callCompleted method.

All of the above is an extremely rough sketch of the idea, and it probably does not compile as I wrote it quickly outside of an IDE. But, it should give you enough details to get started.

Try implementing this approach and posting the result.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Android: Cannot show more than one image