I want to run some Runnable in a background thread. I want to use Handler because it\'s convenient for delays. What I mean is
handler.post(runnable, delay);
You can simply do this:
private Handler mHandler;
private HandlerThread mHandlerThread;
public void startHandlerThread(){
mHandlerThread = new HandlerThread("HandlerThread");
mHandlerThread.start();
mHandler = new Handler(mHandlerThread.getLooper());
}
Then invoke with:
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
// Your task goes here
}
},1000);