Progress indication with animation I have a game in which the player has to do something within a defined time.

E.g.: the player has 10 seconds to complete a level.

My current code animates an imageview (it's only a horizontal line) when the game starts:

progressAnimation = new TranslateAnimation(0, -Settings.screenWidth, 0, 0);
progressAnimation.setDuration(level * 10000);
progressAnimation.setFillAfter(true);
progressAnimation.setInterpolator(new LinearInterpolator());

progressView = new ProgressView(context);
progressView.startAnimation(progressAnimation);


Simultaneously I start a handler:

handler.postDelayed(new Runnable() {
    @Override
    public void run() {
        fireResultActivity(-1); // -1 means, time's up.
    }
}, level * 10000);


If the user can finish the game within 10 seconds an activity comes up and congratulates, if they can't another, "fail" activity comes up.

Is it a good practice to use animation to indicate the progress and start a handler simultaneously?

Could you recommend other (better) solution?
First of All you should be using setAnimationListener on animation object. so no need of Handler 

progressAnimation.setAnimationListener(new Animation.AnimationListener() {
    @Override
    public void onAnimationStart(Animation animation) {

    }

    @Override
    public void onAnimationEnd(Animation animation) {
       fireResultActivity(-1); // call your method here
    }

    @Override
    public void onAnimationRepeat(Animation animation) {

    }
});


As it has built-in listener for Animation, there is no need to create new thread using handler