best practice (Dialog is Open and App is suspended)

16 views
Skip to first unread message

shop.servic...@gmail.com

unread,
May 2, 2019, 9:27:18 PM5/2/19
to CodenameOne Discussions
If you are experiencing an issue please mention the full platform your issue applies to:
IDE: NetBeans/Eclipse/IDEA NetBeans 8.2
Desktop OS Windows 10 Pro
Simulator Latest
Device IOS & Android

I have a case where a dialog is open and the app becomes suspended. (IOS button at bottom was pressed)

Then when the App is resumed, The Dialog is no longer modal/visible, however when re-opening the dialog, I get Internal Application Error, component is already contained in container.

How does one usually handle suspension as it relates to Open Dialogs?

PS: I utilize stop() and handel what is known to me and clean up etc.
        current = Display.getInstance().getCurrent();
        if (current instanceof Dialog) {
            ((Dialog) current).dispose();
            current = Display.getInstance().getCurrent();
        }

How do I get the Dialog to be modal/visible after the app is awoken?

in my start() method, I do this:
        if (current != null) {
            current.show();
         }

Thanks in advance.

Regards.

shop.servic...@gmail.com

unread,
May 2, 2019, 9:42:25 PM5/2/19
to CodenameOne Discussions
Attached is the IOS Error Dialog
DialogErrorAtAppResume_05-02-2019.jpg

Shai Almog

unread,
May 3, 2019, 12:37:37 AM5/3/19
to CodenameOne Discussions
This error occurs when you try to add a component that's already added to another component.
I'm guessing the dialog shows a component which you didn't remove from the now disposed dialog. If such a component exists you can remove it using component.remove().

You can reproduce this on the simulator by triggering suspend/resume in the simulator menu.

shop.servic...@gmail.com

unread,
May 3, 2019, 7:02:56 AM5/3/19
to CodenameOne Discussions
Thanks.
triggering suspend/resume in the simulator menu will be a big help.
You have a great product!

Thanks so much for your continued support.
Reply all
Reply to author
Forward
0 new messages