0

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?

4

3 回答 3

1

您可以new Thread主 UI 线程启动一个处理Bitmap没有问题。它会做你需要做的事情,并且不会以任何方式阻塞主 UI 线程。但是,您不能从新创建的线程直接操作您的UI线程。

在此处查找更多信息:http: //developer.android.com/guide/components/processes-and-threads.html#Threads

于 2013-04-29T04:59:13.420 回答
0

你可以试试Thread

Thread initBkgdThread = new Thread(new Runnable(){
     public void run(){


         //Things that you wanted to do in background here.

      }
});
initBkgdThread.start();
于 2013-04-29T04:24:51.800 回答
0
new Thread(new Runnable()
{   
    @Override
    public void run()
    {
       // Your code here                        
    }
}).start();
于 2013-04-29T04:25:57.067 回答