Thread thread = new Thread() {
public void run() {
try {
while (!isInterrupted()) {
runOnUiThread(new Runnable() {
@Override
public void run() {
// Run your clock code here in a TextView
// Example:
tv.setText(""+((System.currentTimeMillis() - startTime)/1000));
}
});
Thread.sleep(1000); // This refreshes the thread once every second. Adjust as needed.
}
} catch (InterruptedException e) {
e.printStackTrace();
}
}
};
thread.start();