我正嘗試使用的代碼讓我的Android應用程序遠程xml
內容:的Android sdk-獲取遠程XML內容
URL aUrl = new URL(url);
HttpURLConnection conn = (HttpURLConnection)aUrl.openConnection();
conn.setRequestMethod("GET");
conn.setDoOutput(true);
conn.setReadTimeout(15 * 1000); // timeout for reading the google maps data: 15 secs
conn.connect();...
當我嘗試connect()
,我發現了異常:
NetworkOnMainThreadException (id=830019595736)
任何想法?