Android handler function

by mariganesh 2014-03-07 18:57:14

Android handler function

Android handler function is used to run the code in separate time interval like that setinterval function in javascript.



public class MainActivity extends Activity{
public Handler handler,handler1,handler2;
public Runnable mRefresh,mRefresh1,mRefresh2;

protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
init();
}

public void init()

{
handler = new Handler();
mRefresh = new Runnable() {
public void run() {
handler.postDelayed(this, 50);//set the interval time here interval time is 50
/*
Run your Statement...
*/

}
};
mRefresh.run();
}


}

1070
like
0
dislike
0
mail
flag

You must LOGIN to add comments