Reputation: 31
Error:Error: Fragments should be static such that they can be re-instantiated by the system, and anonymous classes are not static [ValidFragment]
private boolean checkFreeSpace(String path, long size) {
long freeSpace = StorageUtil.getAvailableSpaceInBytes(path);
if (freeSpace <= size) {
right there is the probleme>>> new DialogFragment() {
Upvotes: 3
Views: 2763
Reputation: 209
As the documentation says (Fragment Documentation):
Every fragment must have an empty constructor, so it can be instantiated when restoring its activity's state. It is strongly recommended that subclasses do not have other constructors with parameters, since these constructors will not be called when the fragment is re-instantiated; instead, arguments can be supplied by the caller with setArguments(Bundle) and later retrieved by the Fragment with getArguments().
So i guess you are Extending/Implementing a Fragment Class and Overloading a constructor with parameters.
You can fix it using the setArguments(Bundle) method explained above.
Upvotes: 2