我正在访问https网站(sample.aspx),要访问网站我们需要useragent,javascript,cookie必须启用,所以我在浏览器字段中尝试我得到正确的正确响应,在http连接中我无法得到响应。请帮助我如何在http连接中使用以下属性,
String userAgent = "BlackBerry" + DeviceInfo.getDeviceName() + "/" + DeviceInfo.getSoftwareVersion() +" Profile/" + System.getProperty("microedition.profiles") +" Configuration/" + System.getProperty( "microedition.configuration") + " VendorID/" + Branding.getVendorId()
BrowserFieldConfig config = new BrowserFieldConfig();
config.setProperty(BrowserFieldConfig.USER_AGENT, userAgent);
config.setProperty(BrowserFieldConfig.ENABLE_COOKIES,Boolean.TRUE);
config.setProperty(BrowserFieldConfig.JAVASCRIPT_ENABLED, Boolean.TRUE);
myBrowserField = new BrowserField(config);
我需要在我的http连接中启用javascript和cookies。
答案 0 :(得分:0)
你可以打电话给
httpConnection.setRequestProperty("User-Agent",
"Profile/MIDP-2.0 Configuration/CLDC-1.0");