If your update() method is called from a separate Thread repeatedly, it makes sense that you wouldn't see any changes because you're not only not invalidating the View, but could also be swapping the visibility too quickly to tell.
So first, let's declare a blink duration and a holder for our last update time:
private static final int BLINK_DURATION = 350; // 350 ms
private long lastUpdateTime = 0;
private long blinkStart=0;
Now, assuming you're setting setting the Bitmap to be the src or background of the View (which you should be doing if you're animating on top of it), you should be able to draw the text over the View on its Canvas after the View's dispatchDraw(Canvas) call:
@Override
public void dispatchDraw(Canvas canvas) {
Paint paint = new Paint();
paint.setTextSize(40);
paint.setColor(Color.RED);
canvas.drawBitmap(back, width / 2 - back.getWidth() / 2, height / 2
- back.getHeight() / 2, null);
if (blink)
canvas.drawText(blinkText, back.getWidth() / 2,
back.getHeight() / 2, paint);
}
Note: generally you would use onDraw(Canvas), but in this situation the View could be a layout with a background and children, in which case we use dispatchDraw(Canvas) to make sure we actually draw above all the View's children.
Now that we have our drawing method setup, let's adjust your update method to only flip once the duration has passed, and then actually invalidate the View:
public void update() {
if (System.currentTimeMillis() - lastUpdateTime >= BLINK_DURATION
&& !blink) {
blink = true;
blinkStart = System.currentTimeMillis();
}
if (System.currentTimeMillis() - blinkStart >= 150 && blink) {
blink = false;
lastUpdateTime = System.currentTimeMillis();
}
}
Now it is working fine