(HttpConnection) Connector.open(url) 带触摸手机
我正在开发一个 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);
不会引发任何异常,最终显示应用程序的第一个屏幕(主菜单) )。
有什么限制或问题吗?
有什么解决办法吗?
I am working on a J2ME application, it makes a HTTP request and works accordingly to the response received.
Below is my code for HTTP request
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();
}
It is working fine on non touch devices, but when I checked it on Nokia 500 touch phone,
the code executes till line
hcon = (HttpConnection) Connector.open(url);
without throwing any exception, it ends up to show first screen of the application (Main Menu).
Is there any limitation or problem?
Any solution?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否在 jad 中添加了这样的权限
,或者您可以通过以下步骤在 netbean 中添加此权限
右键单击项目
单击“属性”。
单击
单击“应用程序描述符”
选择“API 权限”选项卡
单击“添加”按钮并从列表中添加
javax.microedition.io。 Connecter.http
希望这会对您有所帮助。
Have you added permission in jad like this
or you can add this permission in netbean by following steps
Right Click on project
Click on Properties.
Click on Application Descripter
Select tab API Permission
Click on Add Button And from list add
javax.microedition.io.Connecter.http
Hope this will help you.