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
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.