Code example for Timer

Methods: scheduleAtFixedRate

0
        // We use a layout id because it is a unique number.  We use it later to cancel. 
        nm.notify(R.string.service_started, notification);
    } 
     
    private void incrementCounter() { 
    	timer.scheduleAtFixedRate(new TimerTask(){ public void run() {counter++;}}, 0, 1000L);
    } 
     
    private void shutdownCounter() { 
    	if (timer != null) {
    		timer.cancel();
    	} 
    } 
}