midpjni: how MIDlets can access native services

本博探讨了在MIDP环境下,MIDlet如何通过标准通信协议间接访问本地C++应用的功能,包括建立双向连接进行数据交互,以及权衡此方法对MIDP特性的影响。
Question:
Can I access native functionality from a MIDlet?


Answer:  
Not directly since MIDP does not support JNI.

  • However, it is possible for a MIDlet to communicate with a C++ application running on the host device using a standard communication protocol such as TCP/IP sockets.

    For instance the native application can provide a (server) socket listening for incoming connections on a specific port (say 1234). The MIDlet can then use the GCF to opens a client socket connection using the local loopback address to communicate with the native application as follows:

SocketConnection mySocket = (SocketConnection) Connector.open("socket://127.0.0.1:1234");

Once a two way connection has been established the MIDlet client can make requests for data from the native server using a custom protocol understood by both.

Of course this approach relinquishes many of the tradition strengths of MIDP (such as cross platform portability) requiring as it does the implementation, installation and launching of a dedicated native application as well as the MIDlet. However it may provide a route for application developers to leverage existing Java code to a Java implementation with different capabilities, rather than undertake a complete re-write in C++.

For further information see: http://www.symbian.com/developer/techlib/papers/java_MIDP.asp
"Extending the Reach of MIDlets: how MIDlets can access native services"
and
http://midpjni.com/
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值