Executing code after 1.5 seconds:
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
//The code you want to run after the time is up
}
}, 1500); //the time you want to delay in milliseconds
Executing code repeatedly every 1 second:
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
handler.postDelayed(this, 1000);
}
}, 1000); //the time you want to delay in milliseconds