After restarting my application,
getActivity() returns null in my mainFragment.
Workflow:
When I launch my app, I first start with loginActivity (if not login already), then launch mainActivity.
I got mainFragment attached to my mainActivity. If I unlog() (bringing me back to loginActivity and finish the mainActivity), and start again the same worflow, getActivity() from my fragment return null.
When I see the log, when I first launch the app, I can see that my fragment is detached from the activity when I use the unlog() function
I found several similar questions on SO:
saying this : then you should not use parent(no longer) Activity in the fragment
I would like launch a new activity from my fragment when I click on a button, but how can I do this without using parent Activity in the fragment? (new Intent(this.getActivity(), newActivity.class); returning NPE cause of the null value from getActivity)