java.lang.IllegalStateException:onSaveInstanceState之后无法执行此操作
我正在为我的应用程序使用支持库。在我的FragmentActivity中,我使用AsyncTask从互联网下载数据。在onPreExecute()方法中,我添加一个片段,在onPostExecute()方法中,我再次将其删除。当方向在这两者之间改变时,出现上述异常。请看一下详细信息: private class onFriendAddedAsyncTask extends AsyncTask<String, Void, String> { DummyFragment dummyFragment; FragmentManager fm; FragmentTransaction ft; @Override protected void onPreExecute() { Log.v("MyFragmentActivity", "onFriendAddedAsyncTask/onPreExecute"); dummyFragment = DummyFragment.newInstance(); fm = getSupportFragmentManager(); ft = fm.beginTransaction(); ft.add(dummyFragment, "dummy_fragment"); ft.commit(); } @Override protected void onPostExecute(String result) { Log.v("MyFragmentActivity", "onFriendAddedAsyncTask/onPostExecute"); ft = fm.beginTransaction(); ft.remove(dummyFragment); ft.commit(); } @Override …