0

ユーザーの 1 人 (motorola motorola XT1068) については、onSaveInstanceState の例外が発生しています。クラッシュレポートに ACRA を使用しています。完全なスタック トレースは次のとおりです。

java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
at android.support.v4.app.FragmentManagerImpl.checkStateLoss(FragmentManager.java:1438)
at android.support.v4.app.FragmentManagerImpl.enqueueAction(FragmentManager.java:1456)
at android.support.v4.app.BackStackRecord.commitInternal(BackStackRecord.java:634)
at android.support.v4.app.BackStackRecord.commit(BackStackRecord.java:613)
at android.support.v4.app.FragmentTabHost.onAttachedToWindow(FragmentTabHost.java:282)
at android.view.View.dispatchAttachedToWindow(View.java:13424)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2709)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2716)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2716)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2716)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1315)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1077)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5884)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:767)
at android.view.Choreographer.doCallbacks(Choreographer.java:580)
at android.view.Choreographer.doFrame(Choreographer.java:550)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:753)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5312)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:901)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:696)

しかし、私のアプリケーションソースはどこにも言及されておらず、これは私がsavedinstanceメソッドを使用している唯一の場所です.

@Override
    public void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);
        outState.putBundle("CONFIG", (savedState != null) ? savedState : saveState());
    }
private Bundle saveState() { 
        Bundle state = new Bundle();
        state.putCharSequence("SUCCESS", result.getText());
       state.putCharSequence("FAILURE", error.getText());
        return state;
    }

では、ここで何が問題になる可能性がありますか?

編集

ここに ViewPagerAdapter コードがあります

public class ViewPagerAdapter extends FragmentPagerAdapter {

    private final int PAGES = 3;
    private FragmentManager mFragmentManager;
    private Context mContext;
    private String[] title = new String[]{"Frag1",
            "Frag2", "Frag3"};

    public ViewPagerAdapter(FragmentManager fm, Context context) {
        super(fm);
        mContext = context;
    }

    @Override
    public Fragment getItem(int position) {

        switch (position) {
            case 0:
                return new Fragment1();
            case 1:
                return new Fragment2();
            case 2:
                return new Fragment3();
            default:
                throw new IllegalArgumentException(
                        "The item position should be less or equal to:" + PAGES);
        }
    }

    @Override
    public int getCount() {
        return PAGES;
    }

    @Override
    public int getItemPosition(Object object) {
        return POSITION_NONE;
    }

   @Override
    public CharSequence getPageTitle(int position) {
        return title[position];
    }
}

アクティビティからの呼び出し

viewPageAdapter = new ViewPagerAdapter(getSupportFragmentManager(), getApplicationContext());
4

1 に答える 1

-2

最後にスーパーメソッドを呼び出します。

@Override
public void onSaveInstanceState(Bundle outState) {
    outState.putBundle("CONFIG", (savedState != null) ? savedState : saveState());
    super.onSaveInstanceState(outState);
}
于 2015-10-29T09:31:37.417 に答える