long delay = 3000; // 3 second delay SystemClock.sleep(delay); // code execution resumes after 3 seconds
long start = SystemClock.elapsedRealtime(); // start timer // block of code long end = SystemClock.elapsedRealtime(); // end timer long elapsed = end - start; // get elapsed time (in milliseconds)In both of these examples, the SystemClock class is part of the Android OS package library.