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

0

15

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

Thermogenesis answered 4/12, 2014 at 10:23 Comment(5)
My issue is that animation-list for notification small icon doesn't work at all :(Jurgen
I have the same issue... Have you found a solution ?Mathias
No, but i check if is Android Lollipop, in that case set a image: if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { mBuilder.setSmallIcon(R.drawable.downloading_1); }Thermogenesis
@Jurgen have u found any solution?Autograph
@SalomonBRYS have u found any solution?Autograph

© 2022 - 2024 — McMap. All rights reserved.