android - Showing a DialogFragment throws "Can not perform this action after onSaveInstanceState" error -


problem

hi, i'm creating android , ios module titanium has sendlog method sends arbitrary json data server , returns url if matches predefined filters. url should opened in modal dialog webview.

i've written native ios , android libraries , wrapped them titanium modules. on ios works fine on android can't open dialog (see error stack trace below). right there's 1 log message triggers same webpage testing purposes. on android fails silently.

test case

var mupets = require("be.iminds.mupets"); mupets.initialize("wappr", "http://tocker.iminds.be:3000/log/report.json", 1, 100, 3); var esmlog = {      bar: "foo" }; mupets.sendlog("es-test-01",json.stringify(esmlog)); 

after piece of code (after 10 seconds max), module should show native dialog following webpage inside: http://tocker.iminds.be:3000/es/sheets/test-01/index.html

instead, error consistently:

logs

java.lang.illegalstateexception: can not perform action after onsaveinstancestate @ android.app.fragmentmanagerimpl.checkstateloss(fragmentmanager.java:1411) @ android.app.fragmentmanagerimpl.enqueueaction(fragmentmanager.java:1429) @ android.app.backstackrecord.commitinternal(backstackrecord.java:687) @ android.app.backstackrecord.commit(backstackrecord.java:663) @ android.app.dialogfragment.show(dialogfragment.java:256) @ be.iminds.mupets_client_android.logging.plugins.outhttp.getesm(outhttp.java:122) @ be.iminds.mupets_client_android.logging.plugins.outhttp$1.success(outhttp.java:78) @ be.iminds.mupets_client_android.httpclient$1$1.onresponse(httpclient.java:76) @ okhttp3.realcall$asynccall.execute(realcall.java:133) @ okhttp3.internal.namedrunnable.run(namedrunnable.java:32) @ java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1113) @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:588) @ java.lang.thread.run(thread.java:818) 

here android code that's causing error:

activity activity = (activity) context;                 esmdialogfragment esmdialogfragment = esmdialogfragment.newinstance(new esmdialoglistener() {                     @override                     public void submit(string type, jsonobject result) {                         mupets.sendlog(type, result);                         esmshown = false;                     }                      @override                     public void oncancel(jsonobject cancelled) {                         super.oncancel(cancelled);                         mupets.sendlog("esm_cancelled", cancelled);                         esmshown = false;                     }                 }, url, true);                 fragmenttransaction transaction = activity.getfragmentmanager().begintransaction();                 fragment prev = activity.getfragmentmanager().findfragmentbytag(esmdialogfragment.esm_dialog_fragment);                 if (prev != null) {                     transaction.remove(prev);                 }                 transaction.addtobackstack(null);                 log.v(tag, "pre-show fragment");                 esmdialogfragment.show(transaction, esmdialogfragment.esm_dialog_fragment);                 log.v(tag, "post-show fragment"); 

does titanium either not allow use of fragments/or require call dialog.show() @ specific point? error talks "...after onsaveinstancestate" don't see how call before onsaveinstancestate if i'm not creating activity , why code works when use in native android app.

this titanium example project module should show dialog after opens: https://www.dropbox.com/s/0v77xd5gllv6kb3/testmodule.zip?dl=1

since dialogfragment not have option commitallowingstateloss, simplest solution used set flag when onsaveinstance called , reset on oncreate , onrestoreinstance. before making fragment transaction, check flag sure false. btw, occurs in asynchronous callback. activity gone beyond onsaveinstance time background work has completed , callback has triggered.


Comments

Popular posts from this blog

scala - 'wrong top statement declaration' when using slick in IntelliJ -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

PySide and Qt Properties: Connecting signals from Python to QML -