codenameakshay / async_wallpaper

https://pub.dev/packages/async_wallpaper
MIT License
22 stars 21 forks source link

State reloads 2-3 seconds after apply image as wallpaper #7

Closed AleXoTroN closed 2 years ago

AleXoTroN commented 2 years ago

Describe the bug When i call the method to set the wallpaper (example from file) no matter if i choose home screen, lock screen or both, the states refreshes like 2 or 3 seconds after applying the wallpaper. Its like the app is restarting.

Expected behavior I think it should not be like that.

Flutter:

stefalda commented 2 years ago

I can confirm this behavior, but it's not linked to this plugin, I was using a similar code implementation in another flutter app to change wallpapers and the same happened there... so I tried this plugin and the issue is the same. It seems something linked to the WallpaperManager android class... now I'm gonna try in a 'pure' android application and see if it happens there too...

stefalda commented 2 years ago

I've made the test and it seems to happen even with a Kotlin only Android application. The MainActivity is restarted after setting the wallpaper... I don't know if there's a fix for this, but at least it's not related to Flutter... Beware that if you're setting the same wallpaper already in use, nothing happens, the behavior is observable when the wallpaper is really changed...

stefalda commented 2 years ago

Ok... maybe I've found the cause... It seems something related to Android 12 and Material You Theming, when the wallpaper change ALL activities are restarted so they can react accordingly to the new configuration (adapt their theme I guess).

Unfortunately there seems to be no opt-out of this behavior (and I've lost two days for nothing :-()

https://stackoverflow.com/questions/69741827/android-12-how-to-prevent-activity-restart-on-changing-phone-wallpaper

https://commonsware.com/blog/2021/10/31/android-12-wallpaper-changes-recreate-activities.html

AleXoTroN commented 2 years ago

Thanks for the reply. That's good to know! We should open an issue directly at the Android support.

AleXoTroN commented 2 years ago

Ok... maybe I've found the cause... It seems something related to Android 12 and Material You Theming, when the wallpaper change ALL activities are restarted so they can react accordingly to the new configuration (adapt their theme I guess).

Unfortunately there seems to be no opt-out of this behavior (and I've lost two days for nothing :-()

https://stackoverflow.com/questions/69741827/android-12-how-to-prevent-activity-restart-on-changing-phone-wallpaper

https://commonsware.com/blog/2021/10/31/android-12-wallpaper-changes-recreate-activities.html

Shittt why did I not think about that. That makes sense... So at least if users do mention that, we can say it's not our fault :P

Thanks for the research so far!