Can not perform this action after onSaveInstance错误

测试部挂monkey,跑出个这么个崩溃日志,分析来分析去也没分析出什么问题。

从搜索来看,还是有人遇到这个问题。

记录下。


http://zhiweiofli.iteye.com/blog/1539467


关于onSaveInstance方法和commit方法之间的关系,在FragmentManager.java (./framework/base/core/java/android/app/FragmentManager.java

    /**
     * Start a series of edit operations on the Fragments associated with
     * this FragmentManager.
     *
     * <p>Note: A fragment transaction can only be created/committed prior
     * to an activity saving its state.  If you try to commit a transaction
     * after {@link Activity#onSaveInstanceState Activity.onSaveInstanceState()}
     * (and prior to a following {@link Activity#onStart Activity.onStart}
     * or {@link Activity#onResume Activity.onResume()}, you will get an error.
     * This is because the framework takes care of saving your current fragments
     * in the state, and if changes are made after the state is saved then they
     * will be lost.</p>
     */
    public abstract FragmentTransaction beginTransaction();

从上面可以看出,transaction的创建以及commit必须比activity的save要早。


    private void checkStateLoss() {
        if (mStateSaved) {
            throw new IllegalStateException(
                    "Can not perform this action after onSaveInstanceState");
        }
        if (mNoTransactionsBecause != null) {
            throw new IllegalStateException(
                    "Can not perform this action inside of " + mNoTransactionsBecause);
        }
    }


可以看出。


分析log,量的时候比较轻松,量多了,整个十几个压缩包,真是一件痛苦的事。

因此,分析log掌握方法很有必要。比如查找对应的导致FC的进程id,然后根据这个id 顺藤摸瓜,或者根据事件code,比如keyCode = 4 是返回键,此时,

adb等工具命令排上用场。



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值