Android Fragment lifecycle issue (NullPointerException on onActivityResult)

徘徊边缘 提交于 2019-12-01 23:07:05

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!