讓變化成為計劃的一部分

          歡迎大家探討本Blog涉及的所有軟件課題。我的Google Talk ID:zhengyun(at)gmail.com。

          我最希望軟件帶給用戶的感受是:美好的體驗、舒適感、簡約、干凈...

          posts - 32, comments - 8, trackbacks - 0, articles - 0
            BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理
          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
          主站蜘蛛池模板: 阳信县| 长葛市| 汨罗市| 衢州市| 千阳县| 遂昌县| 高雄县| 宝鸡市| 嘉荫县| 嘉义县| 台东县| 焉耆| 宝山区| 龙里县| 铜山县| 吉安市| 若尔盖县| 旬阳县| 正宁县| 天峻县| 奎屯市| 玛纳斯县| 万山特区| 阿尔山市| 陈巴尔虎旗| 澄城县| 昌邑市| 巩义市| 黑龙江省| 剑川县| 东山县| 新晃| 利川市| 寻乌县| 千阳县| 余姚市| 梁平县| 元阳县| 乾安县| 江西省| 乐安县|