0
在我的應用我顯示一個對話框片段後,我從網絡服務響應。我從onCreate
撥打此服務。如果在應用程序切換到後臺之間,它有例外安卓:DialogFragment節目拋出的Web服務調用後IllegalStateException異常
Fatal Exception: java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
at android.support.v4.app.FragmentManagerImpl.checkStateLoss(FragmentManager.java:1493)
at android.support.v4.app.FragmentManagerImpl.enqueueAction(FragmentManager.java:1511)
at android.support.v4.app.BackStackRecord.commitInternal(BackStackRecord.java:638)
at android.support.v4.app.BackStackRecord.commit(BackStackRecord.java:617)
at android.support.v4.app.DialogFragment.show(DialogFragment.java:139)
at com.activity.MainActivity.showAcceptancePopup(MainActivity.java:1655)
at com.activity.MainActivity.access$1000(MainActivity.java:164)
at com.activity.MainActivity$28.onResponse(MainActivity.java:1568)
at com.activity.MainActivity$28.onResponse(MainActivity.java:1547)
at com.android.volley.toolbox.JsonRequest.deliverResponse(JsonRequest.java:65)
at com.android.volley.ExecutorDelivery$ResponseDeliveryRunnable.run(ExecutorDelivery.java:99)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6123)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:757)
我已經通過了this blog post崩潰。仍然有疑問,從我應該在哪裏打電話dialogFragment.show()
,因爲它依賴於服務器提供的數據。
不然我應該擺脫onCreate
到onResumeFragment
API調用?
可以做到這一點,但我不希望國家損失發生 – Nitish
我明白了,你在哪裏做碎片交易? – Cochi
我從的onCreate使Web服務調用和響應我顯示的對話框。對於API調用,我使用的凌空 – Nitish