Skip to content Skip to sidebar Skip to footer

How Is My Fragment's Oncreateview Called Before It's Oncreate When Finishing The Activity In Oncreate?

This is very odd. I have a simple app which once logged in shows a fragment in an activity. The app also has an inactivity 'timeout' after which time it finishes the activity and s

Solution 1:

After some more debugging I have discovered the exception occurs because of a use of getActivity() before onActivityCreated() is called -- moreover a method is called on getActivity() and the method relies upon the activity having been created. /idiot

Solution 2:

Perhaps you are storing the string in such a way that it is not saved when the fragment goes into the background? Without code that's the only guess I can offer.

One way to fix your problem would be to simply do a null check in your onActivityCreated method. Depends on how you want to handle it though.

Post a Comment for "How Is My Fragment's Oncreateview Called Before It's Oncreate When Finishing The Activity In Oncreate?"