Say I want to draw a line, then wait five seconds, then draw another line. I have a method like this:
public void onDraw(Canvas canvas) {
int w = canvas.getWidth();
int h = canvas.getHeight();
canvas.drawLine(w/2, 0, w/2, h-1, paint);
// PAUSE FIVE SECONDS
canvas.drawLine(0, h/2, w-1, h/2, paint);
}
How do I pause?
Don’t wait in onDraw method it’s called in the UI thread and you’ll block it. Use flags to handle which line will be drawn
Than use it in your code like this