Android 嵌套片段java.lang.IllegalStateException:活动已被销毁

Android 嵌套片段java.lang.IllegalStateException:活动已被销毁,android,android-fragments,Android,Android Fragments,我使用的是嵌套片段。我的代码如下: private void createGrid(List<App> appList) { if(appGridView!=null){ getChildFragmentManager().beginTransaction().remove(appGridView).commitAllowingStateLoss(); getChildFragmentManager().execut

我使用的是嵌套片段。我的代码如下:

 private void createGrid(List<App> appList) {

        if(appGridView!=null){
            getChildFragmentManager().beginTransaction().remove(appGridView).commitAllowingStateLoss();
            getChildFragmentManager().executePendingTransactions();
        }

        appGridView = new AppGridView();


        getChildFragmentManager().beginTransaction().add(R.id.frame_top_app_grid, appGridView).commitAllowingStateLoss();}
但ACRA向我报告了这次事故:

java.lang.IllegalStateException: Activity has been destroyed
at android.support.v4.app.FragmentManagerImpl.enqueueAction(SourceFile:1376)
at android.support.v4.app.BackStackRecord.commitInternal(SourceFile:595)
at android.support.v4.app.BackStackRecord.commitAllowingStateLoss(SourceFile:578)

请帮助我如何解决此问题。

我将createGrid放入:

if(isadded){
creategrid()
}else{
recreate activity
}

问题已解决。

在此错误发生之前,您是否从活动中导航任何内容?您是否没有设置该活动的历史记录?只是问一下,没有导航,也没有历史。ACRA为我报告这次事故。我在开发过程中没有看到过这种崩溃。
if(isadded){
creategrid()
}else{
recreate activity
}