SnackBar icon indicating copy to clipboard operation
SnackBar copied to clipboard

Null Views and NPE when dealing with fragments

Open avsector opened this issue 10 years ago • 0 comments

The validity of a view reference should be checked before attempting to show the SnackBar. When using SnackBar and suppling the view in the builder for the fragments, there's a slight chance that when the SnackBar is building the view is no longer available, hence causing a NullPointerException.

An easy way to produce this is showing SnackBar in asynchronous callbacks in the fragments. Simply start an asynchronous job and navigate away from the fragment.

avsector avatar Feb 21 '15 13:02 avsector