Reputation: 10376
This might be a stupid question, but I'll ask it anyway.
How do you start a background thread off the UI thread without using AsyncTask or Handler or Service or any other Android-provided structure? I want to create a new Thread
to do some Bitmap processing, and given the bugs that were reported against AsyncTask, I'd like to avoid those classes. I know they are the Google-recommended way to background a task, but let's pretend I can't use them...just for fun. :)
If it's not possible, I'd like to know why. If it is, how do I do this?
Upvotes: 0
Views: 361
Reputation: 7037
You can start a new Thread
from the main UI thread for Bitmap
processing no problem. It will do what you need it to do and won't block the main UI thread in any way. However you can't directly manipulate your UI thread from the newly created thread.
Look for more information here: http://developer.android.com/guide/components/processes-and-threads.html#Threads
Upvotes: 1
Reputation: 18151
new Thread(new Runnable()
{
@Override
public void run()
{
// Your code here
}
}).start();
Upvotes: 0
Reputation: 1477
You could try with Thread
Thread initBkgdThread = new Thread(new Runnable(){
public void run(){
//Things that you wanted to do in background here.
}
});
initBkgdThread.start();
Upvotes: 0