getting exception “IllegalStateException: Can not perform this action after onSaveInstanceState”

前端 未结 30 2701
迷失自我
迷失自我 2020-11-22 05:12

I have a Live Android application, and from market i have received following stack trace and i have no idea why its happening as its not happening in application code but it

30条回答
  •  爱一瞬间的悲伤
    2020-11-22 05:43

    Thanks @gunar, but I think there is a better way.

    According to doc :

     * If you are committing a single transaction that does not modify the
     * fragment back stack, strongly consider using
     * {@link FragmentTransaction#commitNow()} instead. This can help avoid
     * unwanted side effects when other code in your app has pending committed
     * transactions that expect different timing.
     *
     * @return Returns true if there were any pending transactions to be
     * executed.
     */
    public abstract boolean executePendingTransactions();
    

    So use commitNow to replace:

    fragmentTransaction.commit();
    FragmentManager.executePendingTransactions()
    

提交回复
热议问题