show dialog when callback for native interface

5 views
Skip to first unread message

Fuad Nassar

unread,
Feb 15, 2019, 4:45:42 PM2/15/19
to CodenameOne Discussions
Device:Android KitKat 4.4.2

hi,
i have something like this class for callback native interface
package com.mycompany;
public class NativeCallback {

   
public static void callback() {
       
// do stuff
   
}

}


and need to show as this Dialog in my static method, without crash my app
Dialog.show("Title", "body", "Ok", null);



note: i try to write like this 
 package com.mycompany;
 
///...
public class NativeCallback {
public static void callback() {
     
     Dialog dlg = new Dialog("At Bottom");
           dlg
.setLayout(new BorderLayout());
           dlg.add(new SpanLabel("Dialog Body text", "DialogBody"));
           int h = Display.getInstance().getDisplayHeight();
           dlg.setDisposeWhenPointerOutOfBounds(true);
           dlg.show(h /8 * 7, 0, 0, 0);
   
}
}


but that does not work and led to crash my app
how i can do it?

Shai Almog

unread,
Feb 16, 2019, 12:29:14 AM2/16/19
to CodenameOne Discussions
Wrap it in callSerially as the callback is probably in the OS native thread.

Fuad Nassar

unread,
Feb 16, 2019, 2:38:01 AM2/16/19
to CodenameOne Discussions
thanks, it's work 
Reply all
Reply to author
Forward
0 new messages