zoukankan      html  css  js  c++  java
  • midpjni: how MIDlets can access native services

    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:

      Also see FAQ-1206
  • 相关阅读:
    腾讯云 Serverless 产品动态 20200827
    双指针 86. 分隔链表(链表 dummyhead)
    双指针:15. 三数之和
    双指针:283. 移动零
    双指针:167. 两数之和 II
    关于数组
    关于抽象类,接口以及多态
    关于字符串
    关于异常
    动手动脑3
  • 原文地址:https://www.cnblogs.com/zhengyun_ustc/p/midpjni.html
Copyright © 2011-2022 走看看