Go Back   Android Forums > Android Development > Application Development
Application Development Dev lounge for our application developers.

test: Reply
LinkBack Thread Tools
Old March 1st, 2010, 02:29 AM   #1 (permalink)
New Member
Thread Author (OP)
Join Date: Mar 2010
Posts: 1
Carrier: Not Provided

Thanks: 0
Thanked 0 Times in 0 Posts
Default Flushing Toast/TextView buffer in While loop

I have a mini app i use to connect to a TCP listener script. The problem i am having is taht when a message is received by the listener script, it will send it to all open sockets currently connected.

Within the Android app, i have a line where i am doing the following:

PHP Code:
while((responseLine is.readLine()) != null)
                if (
responseLine.indexOf("Ok") != -1) {
is.readLine() is the resource returns by DataInputStream. Now, my Listener is set to send a message of Ok if no input has been sent within 30 seconds, so of course, it will break the while. But it is at this point, all messages from the other sockets are displayed via Toast or TextView if I implement that.

Does anyone know of a way to flush Toast or TextView while inside of an indefinite While loop? I know the incoming messages are being appended to the buffer, but can't output until the while is killed?

First stab at Java/Android, extremely familiar with PHP though. In PHP you can just call flush() or ob_flush, etc to clear the buffer, but does not appear you can do that with java.


#iNjection- is offline  
Reply With Quote
sponsored links
Old March 1st, 2010, 02:35 AM   #2 (permalink)
Senior Member
KlaymenDK's Avatar
Join Date: May 2009
Location: Denmark
Posts: 1,221
Device(s): HTC Desire Z (rooted, CyanogenMod v7.1; Revoked ClockworkMod) HTC Desire (rooted, Oxygen rom; Revoke
Carrier: Not Provided

Thanks: 31
Thanked 132 Times in 100 Posts

As I understand it, Toasts are fire-and forget things that you can't subsequently cancel. You can't even get a guarantee they won't be interlaced with Toasts from other apps.
Don't forget to hit the "Thanks" button when someone helps you!!!
How To Ask Questions The Smart Way
-- 010\001\111 --
KlaymenDK is offline  
Reply With Quote
datainputstream, socket, textview, toast

Go Back   Android Forums > Android Development > Application Development
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

All times are GMT -5. The time now is 06:00 PM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.