Midpjni: How midlets can access native services

Source: Internet
Author: User
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 be 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 limit 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/
      Also see FAQ-1206

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.