Fork us on GitHub

Native Interface

Native interfaces allow developers to invoke platform native ...

Native Interface

Picture
Native interfaces allow developers to invoke platform native methods/functions/libraries and even widgets directly from within Codename One without having to adapt your code to every platform. They are a very powerful tool when bridging between Codename One and OS specific features to access functionality that might not yet be exposed in the Codename One platform.

Normally in Java we would use JNI to access "native" however, JNI is designed to access C and we need much more. Codename One allows developers to access Dalvik (Java) when running under Android and defines that as "native", C# when running in Windows Phone and Objective-C when running under iOS. Because of that it is remarkably hard to map arbitrary objects, callbacks and functionality to a native call. So to simplify that work we placed many restrictions on the construction of a native interface, however you can still accomplish pretty spectacular things such as a complete working socket implementation and more.

Check out the new How Do I? video we just published covering native interfaces .


Notice: This post was automatically converted using a script from an older blogging system. Some elements might not have come out as intended.... If that is the case please let us know via the comments section below.

Share this Post:

Posted by Shai Almog

Shai is the co-founder of Codename One. He's been a professional programmer for over 25 years. During that time he has worked with dozens of companies including Sun Microsystems.
For more follow Shai on Twitter & github.