java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState

Appcelerator JIRA | David Vermeir | 7 months ago
  1. 0

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

    Stack Overflow | 6 months ago | Ventis
    java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
  2. 0

    h2. Problem Hi, I'm creating an Android and iOS module for Titanium which has a sendLog method which sends some arbitrary JSON data to a server and returns an URL if it matches some predefined filters. The URL should be opened in a modal Dialog with a webview. I've written native iOS and Android libraries and wrapped them as Titanium modules. On iOS everything works fine but on Android I can't open the Dialog (see error stack trace below). Right now there's one log message that always triggers the same webpage for testing purposes. On Android it just fails silently. h2. Test case {code:lang=javascript|title=app.js} 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)); {code} After this piece of code (after about 10 seconds max), the module should show a native dialog with the following webpage inside: http://tocker.iminds.be:3000/es/sheets/test-01/index.html Instead, this is the error I get consistently: h2. Logs {code:lang=none|title=console} java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState at android.app.FragmentManagerImpl.checkStateLoss(FragmentManager.java:1411) at android.app.FragmentManagerImpl.enqueueAction(FragmentManager.java:1429) at android.app.BackStackRecord.commitInternal(BackStackRecord.java:687) at android.app.BackStackRecord.commit(BackStackRecord.java:663) at android.app.DialogFragment.show(DialogFragment.java:256) at be.iminds.mupets_client_android.logging.plugins.OutHttp.getEsm(OutHttp.java:122) at be.iminds.mupets_client_android.logging.plugins.OutHttp$1.success(OutHttp.java:78) at be.iminds.mupets_client_android.HttpClient$1$1.onResponse(HttpClient.java:76) at okhttp3.RealCall$AsyncCall.execute(RealCall.java:133) at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588) at java.lang.Thread.run(Thread.java:818) {code} Here is the Android code that's causing the error: {code:lang=java|title=Android code} 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"); {code} Does Titanium either not allow the use of Fragments/or require you to call Dialog.show() at a specific point? The error talks about "...after onSaveInstanceState" but I don't see how I would call it before onSaveInstanceState if I'm not creating an activity and why the code works when I use it in a native Android app. I added the Android module and iOS module I use to this ticket.

    Appcelerator JIRA | 7 months ago | David Vermeir
    java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
  3. 0

    h2. Problem Hi, I'm creating an Android and iOS module for Titanium which has a sendLog method which sends some arbitrary JSON data to a server and returns an URL if it matches some predefined filters. The URL should be opened in a modal Dialog with a webview. I've written native iOS and Android libraries and wrapped them as Titanium modules. On iOS everything works fine but on Android I can't open the Dialog (see error stack trace below). Right now there's one log message that always triggers the same webpage for testing purposes. On Android it just fails silently. h2. Test case {code:lang=javascript|title=app.js} 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)); {code} After this piece of code (after about 10 seconds max), the module should show a native dialog with the following webpage inside: http://tocker.iminds.be:3000/es/sheets/test-01/index.html Instead, this is the error I get consistently: h2. Logs {code:lang=none|title=console} java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState at android.app.FragmentManagerImpl.checkStateLoss(FragmentManager.java:1411) at android.app.FragmentManagerImpl.enqueueAction(FragmentManager.java:1429) at android.app.BackStackRecord.commitInternal(BackStackRecord.java:687) at android.app.BackStackRecord.commit(BackStackRecord.java:663) at android.app.DialogFragment.show(DialogFragment.java:256) at be.iminds.mupets_client_android.logging.plugins.OutHttp.getEsm(OutHttp.java:122) at be.iminds.mupets_client_android.logging.plugins.OutHttp$1.success(OutHttp.java:78) at be.iminds.mupets_client_android.HttpClient$1$1.onResponse(HttpClient.java:76) at okhttp3.RealCall$AsyncCall.execute(RealCall.java:133) at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588) at java.lang.Thread.run(Thread.java:818) {code} Here is the Android code that's causing the error: {code:lang=java|title=Android code} 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"); {code} Does Titanium either not allow the use of Fragments/or require you to call Dialog.show() at a specific point? The error talks about "...after onSaveInstanceState" but I don't see how I would call it before onSaveInstanceState if I'm not creating an activity and why the code works when I use it in a native Android app. I added the Android module and iOS module I use to this ticket.

    Appcelerator JIRA | 7 months ago | David Vermeir
    java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    h2. Problem Hi, I'm creating an Android and iOS module for Titanium which has a sendLog method which sends some arbitrary JSON data to a server and returns an URL if it matches some predefined filters. The URL should be opened in a modal Dialog with a webview. I've written native iOS and Android libraries and wrapped them as Titanium modules. On iOS everything works fine but on Android I can't open the Dialog (see error stack trace below). Right now there's one log message that always triggers the same webpage for testing purposes. On Android it just fails silently. h2. Test case {code:lang=javascript|title=app.js} 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)); {code} After this piece of code (after about 10 seconds max), the module should show a native dialog with the following webpage inside: http://tocker.iminds.be:3000/es/sheets/test-01/index.html Instead, this is the error I get consistently: h2. Logs {code:lang=none|title=console} java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState at android.app.FragmentManagerImpl.checkStateLoss(FragmentManager.java:1411) at android.app.FragmentManagerImpl.enqueueAction(FragmentManager.java:1429) at android.app.BackStackRecord.commitInternal(BackStackRecord.java:687) at android.app.BackStackRecord.commit(BackStackRecord.java:663) at android.app.DialogFragment.show(DialogFragment.java:256) at be.iminds.mupets_client_android.logging.plugins.OutHttp.getEsm(OutHttp.java:122) at be.iminds.mupets_client_android.logging.plugins.OutHttp$1.success(OutHttp.java:78) at be.iminds.mupets_client_android.HttpClient$1$1.onResponse(HttpClient.java:76) at okhttp3.RealCall$AsyncCall.execute(RealCall.java:133) at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588) at java.lang.Thread.run(Thread.java:818) {code} Here is the Android code that's causing the error: {code:lang=java|title=Android code} 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"); {code} Does Titanium either not allow the use of Fragments/or require you to call Dialog.show() at a specific point? The error talks about "...after onSaveInstanceState" but I don't see how I would call it before onSaveInstanceState if I'm not creating an activity and why the code works when I use it in a native Android app. I added the Android module and iOS module I use to this ticket.

    Appcelerator JIRA | 7 months ago | David Vermeir
    java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
  6. 0

    crashes when receiving data from p2p server after screen goes to sleep

    GitHub | 2 years ago | door43app
    java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState

  1. szoszi 1 times, last 10 months ago
3 unregistered visitors
Not finding the right solution?
Take a tour to get the most out of Samebug.

Tired of useless tips?

Automated exception search integrated into your IDE

Root Cause Analysis

  1. java.lang.IllegalStateException

    Can not perform this action after onSaveInstanceState

    at android.app.FragmentManagerImpl.checkStateLoss()
  2. Android Platform
    DialogFragment.show
    1. android.app.FragmentManagerImpl.checkStateLoss(FragmentManager.java:1411)
    2. android.app.FragmentManagerImpl.enqueueAction(FragmentManager.java:1429)
    3. android.app.BackStackRecord.commitInternal(BackStackRecord.java:687)
    4. android.app.BackStackRecord.commit(BackStackRecord.java:663)
    5. android.app.DialogFragment.show(DialogFragment.java:256)
    5 frames
  3. be.iminds.mupets_client_android
    HttpClient$1$1.onResponse
    1. be.iminds.mupets_client_android.logging.plugins.OutHttp.getEsm(OutHttp.java:122)
    2. be.iminds.mupets_client_android.logging.plugins.OutHttp$1.success(OutHttp.java:78)
    3. be.iminds.mupets_client_android.HttpClient$1$1.onResponse(HttpClient.java:76)
    3 frames
  4. okhttp3
    RealCall$AsyncCall.execute
    1. okhttp3.RealCall$AsyncCall.execute(RealCall.java:133)
    1 frame
  5. okhttp3.internal
    NamedRunnable.run
    1. okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
    1 frame
  6. Java RT
    Thread.run
    1. java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
    2. java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
    3. java.lang.Thread.run(Thread.java:818)
    3 frames