我正在尝试通过Blackberry模拟器中的Java程序连接到URL。但它没有连接。
try {
HttpConnection httpConn;
StreamConnection s;
s = (StreamConnection)Connector.open("http://www.google.com/");
httpConn = (HttpConnection)s;
status = httpConn.getResponseCode();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
int t=0;
if (status == HttpConnection.HTTP_OK)
{
add(new RichTextField("Successfully Authorized", Field.NON_FOCUSABLE));
}
答案 0 :(得分:0)
s = (StreamConnection)Connector.open("http://www.google.com"+";deviceside=true");
试试这条线...... 如果您尝试使用模拟器,请使用deviceside = true 如果它在移动设备中用于wifi连接,则必须使用interface = wifi