Ser*_*glu 5 android android-fragments crashlytics
我正在开发Android项目->目标SDK版本为25 Build Tools版本为25.0.2
如今,我开始遇到StateLoss Crash。在Google上搜索时,在Stackoverflow上找到了许多答案。
首先,我无法模拟此问题。仅在Crashlytics上看到此问题
Fatal Exception: java.lang.IllegalStateException
Can not perform this action after onSaveInstanceState
Run Code Online (Sandbox Code Playgroud)
在堆栈跟踪中,没有足够的信息可理解。经过一些搜索,我认为问题与提交片段有关。我的示例提交代码如下所示。请注意,所有提交都在内部进行onPostResume()
Fragment f = getSupportFragmentManager().findFragmentByTag("LandingFragment");
android.support.v4.app.FragmentTransaction tr = getSupportFragmentManager().beginTransaction();
if(f == null && !isFinishing() && !isDestroyed()){
f = new LandingFragment();
tr.replace(R.id.onboarding_view_fragment_container, f, "LandingFragment");
tr.commit();
}
Run Code Online (Sandbox Code Playgroud)
在很多文章中,人们都说使用,commitAllowingStateLoss()但是我知道使用非常危险。http://www.androiddesignpatterns.com/2013/08/fragment-transaction-commit-state-loss.html上有一篇很棒的有关片段的文章,
但阅读本文并不能解决我的问题。我无法模拟崩溃,也不知道导致崩溃的原因...有什么想法可以显示出解决方法?
如下所示的示例堆栈跟踪
android.support.v4.app.FragmentManagerImpl.checkStateLoss (SourceFile:1538)
android.support.v4.app.FragmentManagerImpl.enqueueAction (SourceFile:1556)
android.support.v4.app.BackStackRecord.commitInternal (SourceFile:696)
android.support.v4.app.BackStackRecord.commit (SourceFile:662)
android.support.v4.app.FragmentTabHost.onAttachedToWindow (SourceFile:288)
android.view.View.dispatchAttachedToWindow (View.java:13799)
android.view.ViewGroup.dispatchAttachedToWindow (ViewGroup.java:2860)
Run Code Online (Sandbox Code Playgroud)
谢谢
| 归档时间: |
|
| 查看次数: |
2816 次 |
| 最近记录: |