如果我嘗試連接jpeg Camera,這個連接工作正常。但是當我連接到Mjpeg(jpeg-stream)相機時,我無法顯示「System.out.println(」onreturn oncesi「 + httpConnection.getResponseCode());」在輸出控制檯上。 我正在使用模擬器和MDS。我可以在MDS上展示,...流即將到來。我有一個關於HTTPConnection和getResponseCode在BlackBerry上的問題
url = getUrl();
queryString = encodeURL(queryString);
byte postmsg[] = queryString.getBytes("UTF-8");
httpConnection = (HttpConnection) Connector.open(url
+ ";deviceside=false", Connector.READ_WRITE);
httpConnection.setRequestMethod(HttpConnection.GET);
httpConnection.setRequestProperty("Authorization", getBase64Encode());
os = httpConnection.openDataOutputStream();
for (int i = 0; i < postmsg.length; i++) {
os.write(postmsg[i]);
}
{
if (!cancel) {
System.out.println(httpConnection.getURL()+
" *****"+httpConnection.getPort());
System.out.println("onreturn oncesi"
+ httpConnection.getResponseCode());
onReturn(httpConnection.getResponseCode(), httpConnection
.openInputStream(),(int) httpConnection.getLength());
System.out.println("onreturn sornrası");
}
os.close();
httpConnection.close();
}
} catch (Exception e) {
System.out.println("hata " + e.getMessage());
try {
httpConnection.close();
Thread.sleep(60);
} catch (Exception ie) {
}
onError(e);
}
我正在使用4.6 ... ConnectionFactory在4.6中不起作用,我無法取回響應代碼... – atasoyh 2010-11-22 10:17:16
@atasoyh如果打開HTTPS連接,請確保將連接器的結果轉換爲正確的Connection類。我假設您使用授權後,您的連接是通過HTTPS?如果是這樣,投到(HttpsConnection)不(HttpConnection)。同時在谷歌搜索「Marcus Watkins和ConnectionFactory」(適用於4.6),它不是完美的,但它會引導你朝着正確的方向發展。 – eSniff 2010-11-22 18:12:05