Starting thread along with app.

Put your problem here if it does not fit any of the other categories.

Starting thread along with app.

Postby rajuk » Tue Apr 01, 2008 6:00 pm

Hi,

I need to start thread when app is started and keep on running untill the App is closed.

Does anyone can help to do this?

Thanks in advance,
rajuk
rajuk
Freshman
Freshman
 
Posts: 8
Joined: Tue Feb 26, 2008 3:52 am

Top

Postby snailfur » Tue Apr 01, 2008 7:33 pm

Code: Select all
public class myActivity extends Activity
{   
    protected void onCreate(Bundle icicle)
    {
        super.onCreate(icicle);
        Thread mySexyThread = new Thread(new myThreadClass);
        mySexyThread.start();
     }
         class myThreadClass implements Runnable
        {
                public void run()
                {
                        while(!Thread.currentThread().isInterrupted())
                        {
                                // Do magic here...
                        }
                }
         }
}
snailfur
Freshman
Freshman
 
Posts: 6
Joined: Sat Mar 08, 2008 5:22 pm

Postby Rader » Wed Apr 02, 2008 4:04 am

I just solved a problem with threads.
Take a look at this post:
http://www.anddev.org/asynchronously_lo ... t1563.html

Hope it's helpful!
Best regards,

Rader
Rader
Freshman
Freshman
 
Posts: 6
Joined: Thu Mar 06, 2008 8:10 am
Location: China

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: Google Feedfetcher and 23 guests