我有一個奇怪的情況。使用電話和虛擬設備時,所有請求都能正常工作,但如果我嘗試使用Tablet,則無效。使用平板電腦無法獲得urlConnection.getInputStream()
我的要求:
String path = "https://...";
HttpURLConnection urlConnection = null;
try{
URL url = new URL(path);
urlConnection = (HttpURLConnection) url
.openConnection();
urlConnection.setRequestMethod("GET");
urlConnection = Tools.setHeader(urlConnection);
urlConnection.setDoInput(true);
LOG.debug("Start input stream");
InputStream inputStream = urlConnection.getInputStream();
LOG.debug("Input stream exist "+inputStream.toString());
String response = Tools.streamToString(inputStream);
inputStream.close();
JSONObject jsonResponse = new JSONObject(response);
我沒有得到任何錯誤消息。使用代理服務器,我看到我的請求發送和收到的響應。但在程序urlConnection.getInputStream()
方法中什麼都沒有。該計劃不會進一步。我沒有看到第二個日誌。
我試圖設置超時,但這沒有幫助。反應很快(1-2秒)。
我使用的真正平板電腦的Android 5.1版本。 1 – Delphian
你能分享一下嗎? ou正在使用的「URL」,soo,我們可以檢查 –
我不能抱歉。但是我測試了不同的網址並獲得了相同的結果。 – Delphian