我是开发黑莓应用程序的新手。
这三天,我已经从RIM本身的论坛和教程中搜索和学习了。但他们都不能解决我的问题。>.<
所以。我已经尝试了一些不同的方法在 4.6 中通过 BIS 建立 http 连接。
这些是以下代码: 1. HttpConnection httpConnection;
String url = "myURL;deviceside=true";
try{
httpConnection = (HttpConnection) Connector.open(url);
Dialog.inform(">.<");
}
catch(Exception e)
{
Dialog.inform(e.getMessage());
}
从上面的代码 #1 中,没有显示任何对话框。
String url = "myURL"; try { StreamConnection s = (StreamConnection)Connector.open(url); InputStream input = s.openInputStream(); Dialog.inform("sblm byte"); byte[] data = new byte[256]; int len = 0; StringBuffer raw = new StringBuffer(); Dialog.inform("stlh buat byte"); while( -1 != (len = input.read(data))) { raw.append(new String(data, 0, len)); } Dialog.inform("stlh while"); response = raw.toString(); Dialog.inform(response); input.close(); s.close(); } catch(Exception e) { }
与代码 #1 一样,上面的代码也不会弹出任何对话框。
我迫切需要正确的指南来建立简单的 http 连接。有什么我错过的技术吗?我需要为此签名吗?我是否需要在我的 Blackberry 设备(带有 OS 5.00 的 BB 8900)或我的编译器 Eclipse 中进行额外设置?
谢谢你。