Monday, September 17, 2012

How to create thread in Android : Handler class in android : Thread in android


Hello Dear Friends,
    Some time we got error when we create a Thread in android because activity class is also a thread class. For short out this problem we should use Handler class. A little example of handler class are given below-

// create thread
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
public void run() {
// call method
add();
}
//sleep thread for 15 mili second
}, 1500);

No comments :

Post a Comment

Note: Only a member of this blog may post a comment.