我正在处理一个J2ME应用程序,它发出一个HTTP请求,并相应地处理接收到的响应。
下面是我的HTTP请求代码
public String sendHttpGet(String url, String str) throws Exception {
HttpConnection hcon = null;
DataInputStream dis = null;
StringBuffer message = new StringBuffer();
try {
hcon = (HttpConnection) Connector.open(url);
dis = new DataInputStream(hcon.openInputStream());
int ch;
while ((ch = dis.read()) != -1) {
message.append((char)ch);
}
}catch(Exception e){
}finally {
if (hcon != null) {
hcon.close();
}
if (dis != null) {
dis.close();
}
MyForm.show();
}
return message.toString();
}它在非触摸设备上运行良好,但当我在诺基亚500触摸屏手机上查看它时,
代码执行到行。
hcon = (HttpConnection) Connector.open(url);没有抛出任何异常,它最终会显示应用程序的第一个屏幕(主菜单)。
有什么限制或问题吗?
有解决办法吗?
发布于 2012-02-02 13:15:25
你在jad中添加了像这样的权限吗?
MIDlet-Permissions: javax.microedition.io.Connector.http也可以通过以下步骤在netbean中添加此权限
点击Properties.
,
javax.microedition.io.Connecter.http希望这能帮到你。
https://stackoverflow.com/questions/9112246
复制相似问题