×
Namespaces

Variants
Actions

Talk:Accessing native code from Java ME on Symbian

From Nokia Developer Wiki
Jump to: navigation, search
{{{width}}}
28 Sep
2009
Article Review by Larry101 (20090928)

This article discusses a creative approach to overcome the limitations of the Java ME platform in terms of accessing native services. The article begins by discussing the reasons why Java ME has these limitations and discusses the design decisions that were made when designing Java ME with regards to security. For security reasons, Java ME midlets run in what is known as a “sandbox” environment, and are restricted in terms of the native services and data that they are able to access. For this reason, it is often a problem when we want to design midlets which access information such as the call logs or the active processes, because this data is not available via Java. This article outlines an approach which relies on socket communication to allow Java midlets access to native data. A daemon native application (such as a Symbian C++ application) starts when the device boots, and then services requests by midlets for native information. Sample code is provided, demonstrating how the framework would function for the simple example of a midlet which lists the current active processes. This information is sent via the local socket address (127.0.0.1) to the Java midlet. The use of threading is advisable to prevent the application blocking waiting for this data.

The approach described in this article is very interesting and useful. From personal experience, I made use of this architecture in an application I wrote a while back which allowed me to access the Contacts database (without the PIM API) and the call logs from a Java midlet. While the architecture is a bit clumsy – you end up needing two applications to do the work of one – this technique is really an ingenious way for getting around the limitations of Java ME. Having said that, as more and more “additional” APIs are added to Java ME, the need for such “tricks” is perhaps not quite as big as it was a few years ago. The PIM and File Connection APIs now provide access to some of the more commonly used native services and data. Nevertheless, there are still many native services and information sources that are still unavailable from Java midlets. This architecture may in some cases, be the easiest workaround, especially for those who are not well versed in Symbian C++.

A similar architecture could also be implemented using Python instead of Symbian C++ to provide access to native services.


 
×