You can do this with the JavaScript bridge. Just register a java callback function then call it from JavaScript.
See the "calling java methods from JavaScript" section on this page:
--
You received this message because you are subscribed to the Google Groups "CodenameOne Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to codenameone-discu...@googlegroups.com.
Visit this group at http://groups.google.com/group/codenameone-discussions.
To view this discussion on the web visit https://groups.google.com/d/msgid/codenameone-discussions/e8779980-5ac6-45ae-8fa2-50dc1355e61e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.