• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Creating background threadHi I new to android development. Presently i am working on android proj

mindus

Lurker
Hi

I new to android development. Presently i am working on android project and i want to create a background thread which invokes the web service and get the data and insert in to array list. From foreground i need to fetch the data from array list and display in the list view.

I tried to create a background thread. but the problem is all code has execute finally my background thread start executing.

Can anybody have sample program for background thread or anybody give the sample idea for how to do the above concept?

Thanks
mindus
 
I'm using a couple of threads in my game and I think you should be able to do it the same way I did.

//make a class that extends Thread
public class MyBackgroundThread extends Thread
{

//make a run function inside it that does what you want the thread to do
@Override
public void run()

}

//elsewhere in your code; where you want the thread to be created
MyBackgroundThread thread = new MyBackgroundThread();
thread.start();
//I have this in the constructor of a class that is created when the game starts. After the constructor; the thread starts running the game loop.

I hope that helps.
 
Back
Top Bottom