I am creating a live wallpaper app. I want that, in this app after some certain interval a movie object will draw its frame on surfaceHolder
canvas
.
My code is
public void startTimer() {
timer = new Timer();
initializeTimerTask();
}
private void initializeTimerTask() {
timerTask = new TimerTask() {@
Override
public void run() {
Canvas canvas = holder.lockCanvas();
canvas.save();
// Adjust size and position so that
// the image looks good on your screen
canvas.scale(1f, 1f);
movie.draw(canvas, -500, 0);
canvas.restore();
holder.unlockCanvasAndPost(canvas);
movie.setTime((int)(System.currentTimeMillis() % movie.duration()));
}
};
timer.schedule(timerTask, 33);
}
But when I run this app only one frame is shown on the surface and it is not changing over time.
What is the error in my code? How can I see that the surface is changing over time?