If you are using HandlerThread, use HandlerThread.getLooper().quit().
If you are using a raw Thread, you should implement some protocol to
tell the thread to stop itself.
Generally HandlerThread is a lot easier for this kind of stuff, since
it takes care of all of these various details for you.
HI,
I got a simple solution for this after some trials.
instead of creating/starting a new thread for every button click, I
started a thread that listens for button clicks.
But, can I use thread.stop in onDestroy() to kill the thread.
Thanks,
--Jo
On Oct 4, 1:52 pm, Jo <[EMAIL PROTECTED]> wro
also May I know what is the difference between handlerthread.getid and
handlerthread.getThreadId.
In my application this thread will be created and started everytime a
button is clicked(for sending chat message).
so I printed handlerthread.getid and handlerthread.getThreadId.
I get incremented v
THanks Justin,
I would like to use the HandlerThread as it sounds simple compared to
regular threads.
can somebody post a template for using HandlerThread with
android.os.Handler and runnable.
final Handler mHandler2 = new Handler();
HandlerThread android_thread_send;
// Create runnable
Someone pointed out that the runThread member should be declared as
volatile or the behavior of this code is unpredictable.
Cheers,
Justin
Android Team @ Google
On Oct 3, 4:58 pm, "Justin (Google Employee)" <[EMAIL PROTECTED]> wrote:
> Jo,
>
> Sounds like HandlerThread is almost certainly the wa
Jo,
Sounds like HandlerThread is almost certainly the way you want to go
here, but you can do a similar thing with a regular thread, using a
public member to control it. You should stop the the thread in onPause
or onStop depending on what its doing.
public class DummyActivity extends Activity {
OK Hackbod you are taking about quitting handlerThread. Got it. I
thought it was normal java.lang.thread.
Thanks,
--Jyothsna
On Oct 3, 3:32 pm, Jo <[EMAIL PROTECTED]> wrote:
> HI Hackbod,
>
> 1) Thanks about the suggestion. I never used HandlerThread. Maybe I
> can take a look.
>
> 2)coming to t
HI Hackbod,
1) Thanks about the suggestion. I never used HandlerThread. Maybe I
can take a look.
2)coming to the other suggestion.How can I quit a thread. I mean which
method should I use because thread.resume/suspend/stop are all
deprecated.
HI Joe,
I am using a separate daemon thread for rece
This almost sounds like it should be a Service. The thread will only
run when you're Activity is running (basically) and isn't guaranteed
to be kept around once the Activity is cleaned up. You may want a
Service running that can handle this and then you'll have much more
control over it. Will y
Just use HandlerThread to have a single thread sitting there
processing messages that you send to it. Even better, create the
thread in onStart() and quit it in onStop().
On Oct 2, 9:49 pm, Jo <[EMAIL PROTECTED]> wrote:
> HI,
>
> I am developing a chat application. Everytime a user clicks a butt
10 matches
Mail list logo