I use Android Studio 3.3.1
and have an Activity
which encloses a Fragment
:
public class TestActivity extends FragmentActivity {
...
private static class TestFragment extends android.support.v4.app.Fragment {
...
}
}
Android Studio
shows this error, although I can run my application:
fragment class should be public
But I am wondering, because TestFragment
is supposed to be used only in TestActivity
. I did a quick search and only find this answer to a similar question. The answer says:
On orientation change, Activity recreated and framework creates new instance on fragment (and restores previous state). So here to create instance of Fragment, framework asks to provide public constructer.
But the question remains. Why framework asks that when TestActivity
has a complete access to TestFragment
?