Socket in AsyncTask - application crashesso the UI won't be blocked

by Jerry Fan » Wed, 21 Jul 2010 16:41:26 GMT


Sponsored Links
 ou can register a handler in your code and send message to update  your UI
component in Handler. I used this way to solve a similar problem like urs
before. For exapmpel

if (socket.isConnected()) {
OutputStreamOut = new
ObjectOutputStream(socket.
getOutputStream());
InputStreamIn = new
ObjectInputStream(socket.getInputStream());
// everything worked fine until here
//instead of doing this, send msg to a customized
handler
//statusTxt.setText("App is now connected to:\n" +
IP + " : "
mHandler.sendEmptyMessage(UPDATE TEXT); //use
something like this
+ Port); // CRASHING !!!!
connectBt.setText("Disconnect");
connected = true;
continueBt.setVisibility(0);
} else {


On Wed, Jul 21, 2010 at 12:25 AM, stephan <dkn...@googlemail.com> wrote:

>



Other Threads

1. displaying routes on android maps

Hi,

My application is trying to display a path between two points  on
android maps. I was wondering if there is any API for doing it.

If not, any other pointers as to how to accomplish the task?

Any info would be appreciated.

Thanks,
Raghuveer

--~--~---------~--~----~------------~-------~--~----~

2. memory leak when closing and restarting appliction several times

Hi, All!  Using 'ddms' and repeatably clicking SysInfo -> Update from
Device helped me find a memory leak.  So we have 9 JUnit test cases
spread amongst 4 files, and we run them in eclipse.  After EACH test
cases finishes, our application is exiting; and it restarts again for
the next test case.  So for now, that's 9 times our app is closing and
restarting, which would be fine, except that each time it close it
leaks memory so that there is less available for the next test.  All
we have for @before and @after is this:

        @Before
        public void setUp() {
                System.gc();   // <-------- TRIED TO SEE IF THIS WOULD HELP, 
BUT IT
DIDN'T
        startActivity("com.yellowpages.android.ypmobile",
"com.yellowpages.android.ypmobile.YPM");
        waitForStartup();
        }

        @After
        public void postTest() {
                if (wait_post_test) {
                waitFor("class.simpleName", "BASIC_TIMEOUT", timeout_in_ms);
                }
        }

Questions:
1.  What's the proper solution?  Find a way to only start the app ONE
time then run all tests?  Or fix the leak?
2.  To fix the leak, is there something we're missing/forgetting to do
in the @After method?
3.  As a quick fix, is there somewhere particular in the positron code
that I can do a garbage collect() that might help?

Any help is appreciated.
Thanks,

Julie


--~--~---------~--~----~------------~-------~--~----~

3. Additional Libraries Needed when I Built Cupcake for Dream

4. data transfer between android device and pc

5. Doesn't Android-1.0 support Recording Video well?

6. Using Sockets on emulator vs Device

7. How do i save a (large) edited JPEG with full 24bit colordepth without getting OutOfMemoryErrors?