Android Fragment lifecycle issue (NullPointerException on onActivityResult)

后端 未结 1 715
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-23 02:56

I get an issue which for I cannot find any explanation. I have a FragmentActivity that displays fragments using a TabManager, as follows :

public class WorkOrder         


        
1条回答
  •  失恋的感觉
    2021-01-23 03:43

    Ok, I think this can happen if the user has your app open and then hits the home button, then either hits the show running applications button (the one that is to the right of the home button) or holds down the home button on some phones and selects your app to go back to it. Then, if you look at the lifecycle it will call onResume (which is what is in the stack trace above) without calling onCreateView again.

    Fragment Lifecycle

    Now, you should be able to mimic this to see it happening by going into the Developer options on your Nexus 5, and selecting Don't keep activities. Then open your app, go to that fragment hit the home button, then the running apps button and select your app and I think it will show you that exception.

    0 讨论(0)
提交回复
热议问题