2017-07-18 91 views
0

我正在開發天氣應用程序,並使用openweather API來獲取天氣數據。 出於測試目的,我拿來了API的數據,並試圖在日誌打印,但由於某些原因,它不工作,我不斷收到此錯誤: Logs天氣API不加載並且線程繼續暫停

這是我的Java和XML文件:Code

回答

1

while循環將永遠不會停止,因爲你沒有更新的data

data = isr.read();   // read and assign int to data 
while(data!=-1){    // not -1 
    result += (char) data; // add to result 
    isr.read();    // read next 
    // data field value will never be updated inside loop ,hence infinite loop 
    } 

值,以便改變

data = isr.read(); // read and assign char to data 
while(data!=-1){ 
    result += (char) data; 
    data = isr.read(); 
    // data value will never be changes inside loop , infinite loop 
    } 

Gist link for concise approach