我想从J2ME midlet调用Servlet,所以我为Servlet URL编写了HTTPConnection代码来调用GET方法。
当Midlet套件尝试连接到Servlet URL时,我在Emulator中收到以下消息:
{#MyMidlet} Midlet Suite wants to connect to {#Servlet URL} using air time,
this may result in charges, Is it ok to use airtime ?如果我单击No或Yes,什么都没有发生,它只是挂起了,我使用的是EclipseME和SUN WTK2.5.2。在控制台上有一个警告,
Warning: To avoid potential deadlock, operations that may block, such as
networking, should be performed in a different thread than the
commandAction() handler.这意味着,如果我在单独的线程中创建HttpConnection,问题会得到解决吗?
发布于 2012-07-26 19:37:25
将其连接创建为单独的线程,如下所示:
Thread myConnection = new Thread(new Runnable() {
public void run() {
// TODO open connection here
HttpConnection conn = null;
try {
conn = (HttpConnection) Connector.open(serverURL,
Connector.READ_WRITE, true);
conn.setRequestMethod(HttpConnection.GET); // or POST method
} catch (Exception e) {
// TODO: handle exception
} finally {
// close connection here
}
}
});
myConnection.start();发布于 2012-07-26 17:16:10
在J2ME中,网络操作被放在单独的线程中。
如果您将网络模块放在单独的thread.If中,将网络模块放在单独的线程中,则不会出现以下消息。
Warning: To avoid potential deadlock, operations that may block, such as
networking, should be performed in a different thread than the
commandAction() handler.在J2ME (sun/甲骨文谁是j2me的所有者)给一些limitations.For的安全需要的一些API的可信方certificates.For这一些手机要求用户许可当用户点击是,然后它将允许,否则它将不允许。
以下是FileConnection (文件读写)接口、HttpConnection、HttpsConnection等场景下的一些接口。
你检查你的设备是否支持自签名certificate.If意味着你使用了自签名证书。
信任方证书非常昂贵,最低费用为每year.The 10000卢比。下面是一些信任方供应商,如: Thawte,Verizon,Semantec等
https://stackoverflow.com/questions/11664355
复制相似问题