Android-CleanArchitecture icon indicating copy to clipboard operation
Android-CleanArchitecture copied to clipboard

NullPointerException on UserListFragment activity recreated

Open CristianMG opened this issue 8 years ago • 0 comments

Hi All

I have encountered a problem when you activate the activity kill a null pointer exception occurs, I put into practice what is advised in this web https://medium.com/inspace-labs-blog/efficient-and-bug-free- fragment-injection-in-android-mvp-applications-1245a3dd5a9 # .u91v46vvs

But I encounter the problem that the fragment in the onCreateView not have injected dependencies.

Another approach is to change the order of the super and put it above the method onCreate

     @Override
    protected void onCreate(Bundle savedInstanceState) {
        this.getApplicationComponent().inject(this);
        super.onCreate(savedInstanceState);
    }

What would be the optimal way to solve this problem?

It does not seem right that when the activity is created to use my presenter and when it can not use recreates prevents me put code in the onCreateView the fragment.

CristianMG avatar Sep 16 '16 15:09 CristianMG