How to Communicating between a J2ME Midlet and PC?

强颜欢笑 提交于 2019-12-11 02:18:18

问题


How do I make a J2ME Midlet to communicate with a java program or some application on the pc through the cable connected?


回答1:


Incredible_Honk is almost right. The key is to use the (standard) system property "microedition.commports". This provides a comma delimited list of the com ports which are available to your application. To open a connection use CommConnection as follows:

CommConnection con = (CommConnection) Connector.open("com:<commport name>");

Usually this will provide access to a USB serial connection, possibly also infrared if available. Iterate through each one to see which one corresponds to the connection you're looking for.

On Windows at least, you will need to install the correct drivers for your handset first. This will then allow you to open a serial connection and communicate with the application.




回答2:


There is no general way of doing this. It hardly depends on the capabilities of the mobil. Might be that there is some vendor API giving you special access to USB, but I'm not aware of any.

Some phones support communication via serial port connections. Take a look at the javax.microedition.io.CommConnection interface for more information.




回答3:


Sonyericsson phones offer a way to debug your midlet on the device and get the console messages back through the cable.



来源:https://stackoverflow.com/questions/1398504/how-to-communicating-between-a-j2me-midlet-and-pc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!