The Animation-list restart when I update (NotificationManager.notify) notifications on Lollipop

532 views Asked by At

I have implemented a notification that contains an animation when my app downloads a file, it was working perfectly until Lollipop appeared.

public void createNotification(String filename) {        
    mBuilder = new Notification.Builder(this);
    mBuilder.setContentTitle(filename);
    mBuilder.setContentText(getString(R.string.downloading));
    mBuilder.setSmallIcon(R.drawable.notification_downloading);
    //mBuilder.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.downloading_1));
    mBuilder.setProgress(100, 0, false);
    mBuilder.setAutoCancel(true);
    mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    mNotificationManager.notify(0, mBuilder.build());
}

//Method to update progressbar
public void updateNotification(int progress) {
    mBuilder.setProgress(100, progress, false);
    mBuilder.setContentText(getString(R.string.downloading) + " " + progress + "%");
    mNotificationManager.notify(0, mBuilder.build());
}

notification_downloading.xml

<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="false">
<item
    android:drawable="@drawable/downloading_1"
    android:duration="@integer/animation_interval_duration" />
<item
    android:drawable="@drawable/downloading_2"
    android:duration="@integer/animation_interval_duration" />
<item
    android:drawable="@drawable/downloading_3"
    android:duration="@integer/animation_interval_duration" />
</animation-list>

Every call to "mNotificationManager.notify" restarts the animation (only in Lollipop)

If I call "set large icon", this behavior keeps happening

I don't want to set progress indeterminate

Is this a bug? Thanks

UPDATE: Still happening with Android 5.0.1

0

There are 0 answers