Restarting the animation list when updating notifications (NotificationManager.notify) on Lollipop

I implemented a notification containing animation, when my application uploads a file, it works fine until Lollipop appears.

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> 

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

If I call "set large icon" this behavior continues to occur

I do not want to set progress uncertain

This is mistake? Thanks

UPDATE: still happening with Android 5.0.1

+6
source share

Source: https://habr.com/ru/post/979099/


All Articles