ValueAnimator doesn't seem to repeat or play animators that are repeated infinitely when the battery saver is enabled in Android lollipop or higher.
animator = ValueAnimator.ofInt(0,timePeriods.length-1);
animator.setInterpolator(new LinearInterpolator());
animator.setEvaluator(new TypeEvaluator() {
@Override
public Object evaluate(float v, Object o, Object t1) {
int time = 0 ;
int timeElapsed = (int)(v*totalTime) ;
for (int i = 0; i < timePeriods.length; i++) {
time = time + timePeriods[i];
if(time>=timeElapsed) return i ;
}
return 0 ;
}
});
animator.setDuration(totalTime);
animator.setRepeatCount(repeatCount);
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
int currentValue = -1 ;
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
int value = (Integer) valueAnimator.getAnimatedValue();
if(value!=currentValue){
Log.d(TAG,"Value Changed: "+currentValue+" "+value);
currentValue = value ;
}
}
});
When the battery saver is enabled the animator plays the animation only once and doesn't repeat after that... Is there any setting|Flag within the application or activity to run animators even in low battery mode as the above animator is a simple integer valueanimator and doesn't drain the battery any further.