new Handler().postDelayed(<Runnable object>,<m seconds>); private final Runnable func= new Runnable(){ @Override public void run(){ } };
private Handler mHandler = new Handler(); private Runnable updateText; @Override protected void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); updateText = new Runnable(){ public void run(){ TextView text = (TextView) findViewById(R.id.count); Integer count = Integer.valueOf(text.getText().toString()); count += 1; text.setText(count.toString()); mHandler.removeCallbacks(updateText); mHandler.postDelayed(updateText, 1000); } }; mHandler.postDelayed(updateText, 1000); }