0

I create an app to periodically set wallpaper. It works fine for Android < 12, from Android 12+ the new feature "Dynamic Color" causes the app's activity restart whenever the wallpaper changed.

If I am in the app and there is currently a dialog showing and the wallpaper is changed, the app will crash with error "android.view.WindowLeaked: Activity [my activity] has leaked window DecorView" if I am doing something with the dialog (reference to old activity instance). It is because of the activity recreation.

I also cannot exclude the activity from configuration changes because it cannot with the Dynamic Color. See the doc Some configuration changes always cause the activity to restart

If I go to Settings -> Wallpaper & Style to disable Dynamic Color, everything go back to normal.

I've many crash reports in Play Console (on Android 13) because of this issue.

How to fix this issue on Android 12, 13+ when Dynamic Color is enabled.

leegor
  • 472
  • 5
  • 15

1 Answers1

1

Unfortunately, this don't have a workaroud to fix it. I have the same behavior in my app.

This is an Android 12+ issue. You can see more info about in this question.

Some other links which can be useful.
https://issuetracker.google.com/issues/199995249
https://commonsware.com/blog/2021/10/31/android-12-wallpaper-changes-recreate-activities.html

Dourado
  • 110
  • 8
  • The users of my app set the wallpaper changer interval in just 10 seconds or so and report me many apps refreshing or crashing when they are doing something. I think the only way is to show an popup, tell and instruct user to disable "Dynamic Color" for now. – leegor Mar 26 '23 at 06:45