J2ME上做东西,难免想调一个系统资源,取个系统数据之类。
J2SE有runtime.exec,J2ME就只能靠platformRequest了,扔个String过去,设备会对不同的请求做不同的响应
扔个"http://..................",设备应该会打开浏览器,连接网页
扔个"tel:....................",设备应该会拨打一个电话
请注意,只是“应该”。规范是这么定的,设备究竟会怎么响应,不知道。。。。设备会不会甩你,不知道。。。。
J2ME针对platformRequest有一大段文档,把这个问题讲的很清楚。干这一行这么多年了,还是犯了不仔细看文档就写代码的老毛病,惭愧。。。。
public final boolean platformRequest(String URL) throws ConnectionNotFoundException
Requests that the device handle (for example, display or install) the indicated URL.
If the platform has the appropriate capabilities and resources available, it SHOULD bring the appropriate application to the foreground and let the user interact with the content, while keeping the MIDlet suite running in the background. If the platform does not have appropriate capabilities or resources available, it MAY wait to handle the URL request until after the MIDlet suite exits. In this case, when the requesting MIDlet suite exits, the platform MUST then bring the appropriate application (if one exists) to the foreground to let the user interact with the content.
This is a non-blocking method. In addition, this method does NOT queue multiple requests. On platforms where the MIDlet suite must exit before the request is handled, the platform MUST handle only the last request made. On platforms where the MIDlet suite and the request can be handled concurrently, each request that the MIDlet suite makes MUST be passed to the platform software for handling in a timely fashion.
唉,J2ME真是后妈养的。。。。
J2SE有runtime.exec,J2ME就只能靠platformRequest了,扔个String过去,设备会对不同的请求做不同的响应
扔个"http://..................",设备应该会打开浏览器,连接网页
扔个"tel:....................",设备应该会拨打一个电话
请注意,只是“应该”。规范是这么定的,设备究竟会怎么响应,不知道。。。。设备会不会甩你,不知道。。。。
J2ME针对platformRequest有一大段文档,把这个问题讲的很清楚。干这一行这么多年了,还是犯了不仔细看文档就写代码的老毛病,惭愧。。。。
public final boolean platformRequest(String URL) throws ConnectionNotFoundException
Requests that the device handle (for example, display or install) the indicated URL.
If the platform has the appropriate capabilities and resources available, it SHOULD bring the appropriate application to the foreground and let the user interact with the content, while keeping the MIDlet suite running in the background. If the platform does not have appropriate capabilities or resources available, it MAY wait to handle the URL request until after the MIDlet suite exits. In this case, when the requesting MIDlet suite exits, the platform MUST then bring the appropriate application (if one exists) to the foreground to let the user interact with the content.
This is a non-blocking method. In addition, this method does NOT queue multiple requests. On platforms where the MIDlet suite must exit before the request is handled, the platform MUST handle only the last request made. On platforms where the MIDlet suite and the request can be handled concurrently, each request that the MIDlet suite makes MUST be passed to the platform software for handling in a timely fashion.
唉,J2ME真是后妈养的。。。。
本文探讨了J2ME中使用platformRequest方法调用系统资源的过程。该方法允许MIDlet套件请求设备处理特定URL,例如打开网页或拨打电话等操作。然而,设备是否支持这些请求以及如何响应取决于具体的实现。
281

被折叠的 条评论
为什么被折叠?



