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真是后妈养的。。。。