I'm facing an issue which hopefully you can help me to fix. In my Android app, I display a Snackbar using the usual way (
). However, I also have to deal with configuration changes (like orientation changes from portrait to landscape).
Now if the configuration changes, the Snackbar disappears, which is nothing I wouldn't expect. I had the same issue with ProgressDialog and AlertDialog, which I solved by using a custom subclass of DialogFragment.
I also had this issue with my AsyncTasks which I solved by using a custom subclass of Fragment which I retain (
of the Fragment) and which keeps a reference to my AsyncTask. In both cases, each Fragment has a callback interface which the Activity has to implement and I set/unset the callback during
However, Snackbar seems to be different because it is attached to a View instead of a Context like for example the ProgressDialog (in
of my DialogFragment I can use new
So when and how shall I display a Snackbar after a configuration change? Is using a Fragment the way to go or should I try to work around this by having some private variables on my Activity which I save/restore via the