BlackBerry应用无法与服务器建立Http连接
这是我用于HTTP连接的代码:BlackBerry应用无法与服务器建立Http连接,http,connection,blackberry-simulator,blackberry-eclipse-plugin,Http,Connection,Blackberry Simulator,Blackberry Eclipse Plugin,这是我用于HTTP连接的代码: HttpConnection connection = null; // InputStream inputstream = null; connection = (HttpConnection) Connector.open("http://www.google.com"); //HTTP Request connection.setRequestMethod(HttpConnection.GET); connection.setRequestProperty(
HttpConnection connection = null;
// InputStream inputstream = null;
connection = (HttpConnection) Connector.open("http://www.google.com");
//HTTP Request
connection.setRequestMethod(HttpConnection.GET);
connection.setRequestProperty("Content-Type","//text plain");
connection.setRequestProperty("Connection", "close");
add(new LabelField(""+connection.getResponseMessage()));
connection.close();
这本名为“工作”的黑莓开发指南
这本名为“工作”的黑莓开发指南
ConnectionFactory connFact = new ConnectionFactory();
ConnectionDescriptor connDesc;
connDesc = connFact.getConnection("http://www.google.com");
if (connDesc != null) {
HttpConnection httpConn;
httpConn = (HttpConnection)connDesc.getConnection();
try {
final int iResponseCode = httpConn.getResponseCode();
UiApplication.getUiApplication().invokeLater(new Runnable() {
public void run() {
Dialog.alert("Response code: " +
Integer.toString(iResponseCode));
}
});
} catch (IOException e) {
System.err.println("Caught IOException: " + e.getMessage());
}
}