Closed cushon closed 10 years ago
Original comment posted by eaftan@google.com on 2014-03-04 at 12:45 AM
This is a reasonable request, but this check probably belongs in Android Lint rather than in error-prone, since it is Android specific. I would suggest filing it there: http://tools.android.com/tips/lint
Status: WontFix
Original issue created by fergal@google.com on 2014-02-04 at 04:51 AM
Non-abstract classes that inherit from android.app.Fragment and a variety of other Android classes should always be public otherwise the framework cannot instantiate them.
If a class is not public, your app can instantiate it and everything will look ok but if you app is backgrounded and then killed off by Android, when it is resumed, the classes are then re-instantiated by the system and at that point your app fails.
It's hard to think of an example of a concrete class that needs to be non-public but extends one of these. I could see how people could make them during testing etc but I can't see how it would be necessary to keep them private or harmful to make them public.
Even-so the ability to warn (and suppress warnings) about this would be useful.
PostiveCases:
class Foo1 extends android.app.DialogFragment { ... }
private class Foo2 extends android.app.DialogFragment { ... }
NegativeCases:
public class Foo3 extends android.app.DialogFragment { ... }
private abstract class Foo4 extends android.app.DialogFragment { ... }