Skip to content
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

程序压入后台,BeamListFragment会报空指针。 #9

Open
gohhng opened this issue Apr 20, 2016 · 2 comments
Open

程序压入后台,BeamListFragment会报空指针。 #9

gohhng opened this issue Apr 20, 2016 · 2 comments

Comments

@gohhng
Copy link

gohhng commented Apr 20, 2016

Activity中使用BeamListFragment,程序压入后台(如按home键,用360卫士清理内存),再恢复时,会报空指针。
原因可能是:
压入后台, Fragment可能会系统回收了,Presenter中的view=null了。再恢复时,没有走Fragment的onCreate方法,只走了onCreateView ,

这时在onCreateView 中执行:

if (mListConfig.mStartWithProgress&&!getPresenter().inited) mListView.setAdapterWithProgress(mAdapter = getPresenter().getAdapter());
else mListView.setAdapter(mAdapter = getPresenter().getAdapter());

DataAdapter引用的getview就空指针异常了。

@Jude95
Copy link
Owner

Jude95 commented May 7, 2016

抱歉拖了这么久才有空。
有错误log吗。我这边怎么实验都没问题。
Fragment被回收再恢复肯定要走onCreate方法。走了onCreate就能重新绑定。

@Jude95
Copy link
Owner

Jude95 commented May 8, 2016

另外据我所知。AMS在内存不足时,是将进程信息(包含Activity)保存到AMS,再杀掉进程。
不可能存在Activity/Fragment被回收。而进程却存在的情况吧?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants