简体   繁体   中英

How to Communicating between a J2ME Midlet and PC?

如何通过连接的电缆使J2ME Midlet与PC上的Java程序或某些应用程序通信?

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.

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.

索尼爱立信手机提供了一种在设备上调试Midlet并通过电缆将控制台消息返回的方法。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM