I want commit a fragment after network background operation. I was calling commit() after successful network operation but in case activity goes to pause or stop state it was cr
Just check whether activity is finishing or no, and then commit()
the transaction.
if (!isFinishing()) {
// commit transaction
}
The exception you get is in a scenario, when activity is being finished, and you are trying to commit a new transaction, which obviously won't be saved by FragmentManager
because the onSavedInstanceState()
has already been executed. That's why framework forces you to implement it "correctly".