New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NPE in fragment inject #124
Comments
3e2e382#commitcomment-16642857 To reproduce: switch ON Don't keep activities under Apps in Settings/Developer options. This will destory every activity as soon as the user leaves it. |
Well, I suppose i fixed this issue. The reason is that the code which create fragment component in activity doesn't executed. Most of the time it works well, but when activity goes to background and is called after some time, FragmentController tries to restore fragment (in onCreate() callback in FragmentActivity.class), that's why dependencies's injections in fragment happen before fragment component initialization in activity. That's why NPE occures. |
Could this be provided as PR here? |
You may find this interesting: Efficient and bug-free fragment injection in Android MVP applications on medium.com |
The problem is when the application stays in the backgound for a while and a recently displayed activity is recycled by Android. Bringing back the application causes NPE as the activity's component is called by the fragment before it is initialized. In my case it often happens after pushing on notification which starts new activity. This issue is very hard to reproduce. By the way this issue occurs only on my device with android 5.
The text was updated successfully, but these errors were encountered: