android - Fatal Exception: java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState -


i show dialogfragment inside button onclick event below:

public void  onbuttonclick() {     mydialogfragment.show(getsupportfragmentmanager(), "dialog"); } 

why cause illegalstateexception, may called after onsaveinstancestate? here log:

fatal exception: java.lang.illegalstateexception: can not perform action after onsaveinstancestate    @ android.support.v4.app.fragmentmanagerimpl.checkstateloss(fragmentmanager.java:1377)    @ android.support.v4.app.fragmentmanagerimpl.enqueueaction(fragmentmanager.java:1395)    @ android.support.v4.app.backstackrecord.commitinternal(backstackrecord.java:637)    @ android.support.v4.app.backstackrecord.commit(backstackrecord.java:616)    @ android.support.v4.app.dialogfragment.show(dialogfragment.java:139)    @ com.a.b.afragment.editsex(afragment.java:226)    @ com.a.b.afragment.access$200(afragment.java:46)    @ com.a.b.afragment$3.onbuttonclick(afragment.java:134) 

inside show method call

fragmenttransaction.commitallowingstateloss() 

after adding fragment

fragmenttransaction.add(); 

for reference

like commit allows commit executed after activity's state saved. dangerous because commit can lost if activity needs later restored state, should used cases okay ui state change unexpectedly on user.


Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -