Есть активити (AcMain), внутри этого активити расположенно несколько фрагментов, в одном из этих фрагментов (FrOne) нужно запустить вложенный фрагмент (FrOne__FrNested) после вызова onActivityResylt.
Внутри FrOne такой код:
private void clickButton() {
startActivityForResult(intent, REQUEST_CODE_ADD_VIDEO);
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
switch (requestCode) {
case REQUEST_CODE_ADD_VIDEO:
getChildFragmentManager().beginTransaction()
.add(layoutForAllFragmentsFR_ONE.getId(), new FrOne_FrNested))
.addToBackStack(null)
.commit();
break;
}
}
Проблема в том что с помощью childFragmentManager я не могу добавить фрагмент, но с помощью обычного fragmentManager все добавляется нормально.
Ошибка при добавлении с помощью сhildFM:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.max.sloustep, PID: 1153
java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=65538, result=-1, data=Intent { dat=content://media/external/video/media/42964 flg=0x1 }} to activity {com.example.max.sloustep/com.example.max.sloustep.activities.AcMain}: java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
at android.app.ActivityThread.deliverResults(ActivityThread.java:3852)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:3895)
at android.app.ActivityThread.access$1600(ActivityThread.java:154)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1445)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5582)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
at android.support.v4.app.FragmentManagerImpl.checkStateLoss(FragmentManager.java:1842)
at android.support.v4.app.FragmentManagerImpl.enqueueAction(FragmentManager.java:1860)
at android.support.v4.app.BackStackRecord.commitInternal(BackStackRecord.java:650)
at android.support.v4.app.BackStackRecord.commit(BackStackRecord.java:609)
at com.example.max.sloustep.fragments.FrProfile.onActivityResult(FrProfile.java:311)
at android.support.v4.app.FragmentActivity.onActivityResult(FragmentActivity.java:164)
at android.app.Activity.dispatchActivityResult(Activity.java:6526)
at android.app.ActivityThread.deliverResults(ActivityThread.java:3848)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:3895)
at android.app.ActivityThread.access$1600(ActivityThread.java:154)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1445)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5582)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)