Thursday, November 3, 2011

What is Handler?

Handler is a class that is tied tightly into the message queue and loop that forms the backbone of the main application thread. The primary purpose of a Handler in application code is to arrange for messages to be sent from background threads to the main application thread, mostly to arrange for updates to the UI, which cannot be done from background threads.

For eg:

Handler handleVal = new Handler();

Runnable runVal = new Runnable() {
@Override
public void run() {
//Your back ground process
}
};
handleVal.post(runVal);

No comments:

Post a Comment