Code example for Chronometer

Methods: getText, setBase, start

0
			@Override 
			public void onClick(View arg0) {
				 
				int stoppedMilliseconds = 0;
				 
				String chronoText = timeWaitingChronometer.getText().toString();
				String array[] = chronoText.split(":");
				 
				if(array.length == 2) {
					 
					stoppedMilliseconds = Integer.parseInt(array[0]) * 60 * 1000 + 
										  Integer.parseInt(array[1]) * 1000;
					 
				} 
				else if(array.length == 3) {
					 
					stoppedMilliseconds = Integer.parseInt(array[0]) * 60 * 60 * 1000 + 
										  Integer.parseInt(array[1]) * 60 * 1000 +
										  Integer.parseInt(array[2]) * 1000;
 
					 
				} 
				 
				timeWaitingChronometer.setBase(SystemClock.elapsedRealtime() - stoppedMilliseconds);
				 
				secondsYouWaited = Long.parseLong(array[1]);
				 
				updateTipBasedOnTimeWaited(secondsYouWaited);
				 
				timeWaitingChronometer.start();
								 
			} 
			 
		});