What is the difference between commit() and commitAllowingStateLoss() in Fragments

前端 未结 2 382
后悔当初
后悔当初 2020-12-05 12:54

I was using the commit method in my project that built it with fragments.

Anyway, sometimes I was getting IllegalStateException: Can not perform this action a

2条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-05 13:25

    There is only one difference between commit() and commitAllowingStateLoss(): the latter doesn't throw an exception if state loss occurs. Other than that, they have identical behavior.

    See my blog post about this topic for more information.

提交回复
热议问题