2 messages in com.googlegroups.android-beginners[android-beginners] Re: android freez...
FromSent OnAttachments
Pedro Cristovão19 May 2008 03:41 
Justin (Google Employee)21 May 2008 13:59 
Subject:[android-beginners] Re: android freezing with Looper
From:Justin (Google Employee) (j.@google.com)
Date:05/21/2008 01:59:04 PM
List:com.googlegroups.android-beginners

Pedro,

What are you trying to accomplish exactly here? If you are just trying to show a message to the user for a certain period of time, all you need is Toast.makeText().

If you are using a looper you need to create add a Handler member to your class that will receive and process messages from the message loop. Presumably the Handler then contains some logic to call Looper.myLooper().quit(). When Looper.loop() is called your thread will go into the message handling loop until some code that executes in that loop (from your Handler) tells the loop to stop.

I've posted a sample of using the Looper class in a file called dorothy.zip

Cheers, Justin

On May 19, 3:42 am, Pedro Cristovão <pcri@gmail.com> wrote:

hi all.

my android application freezes when using the Looper.prepare() -> Looper.loop() -> Looper.myLooper().quit() sequence. here's the code where it blocks:

public void endData() { String result = new String(baf.toByteArray());

Looper.prepare(); Toast.makeText(myActivity, result, Toast.LENGTH_SHORT).show(); Looper.loop();

Looper.myLooper().quit();

}

any sugestion of what the problem might be?

thanks in advance,