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 you be handing incoming messages the same way?

http://code.google.com/android/reference/android/app/Service.html

On Oct 3, 4:03 am, hackbod <[EMAIL PROTECTED]> wrote:
> 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 button a
> > thread needs to handle it as text message needs to be sent over
> > network. so, I am creating a new thread each time when the user clicks
> > on button.  I wish only 1 thread handles all the messages to be sent.
> > But, resume/suspend/stop are all deprecated.
>
> > is there a way to do it.
>
> > currently, I am doing it like the following.
>
> > <code>
> > View.OnClickListener showChat = new View.OnClickListener() {
> >                         @Override
> >                         public void onClick(View v) {
>
> >                                 t_send = new Thread() {
> >                                         public void run() {
> >                                                 recv = false;
> >                                                 m_mychat = 
> > doExpensiveSend();
>
> >                                                 
> > mHandler2.post(mUpdateResults2);
> >                                         }
> >                                 };
> >                                 t_send.start();
>
> >                         }
> >                 };
> > </code>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to