在我的應用程序中,我下載並解析了一個html頁面。不過,我希望能夠在其曲目中停止下載(即當用戶點擊取消時)。Android停止下載
這是我現在使用的代碼,它正在從doInBackground稱爲從的AsyncTask。
如何取消從的AsyncTask外的這一要求?
我目前使用htmlcleaner
HtmlCleaner cleaner = new HtmlCleaner();
CleanerProperties props = cleaner.getProperties();
props.setAllowHtmlInsideAttributes(true);
props.setAllowMultiWordAttributes(true);
props.setRecognizeUnicodeChars(true);
props.setOmitComments(true);
try {
URL url = new URL(urlstring);
URLConnection conn = url.openConnection();
TagNode node = cleaner.clean(new InputStreamReader(conn.getInputStream()));
return node;
} catch (Exception e) {
failed = true;
return;
}
這是否也會自動停止下載?我使用URLConnection類下載。 – 2011-02-06 16:49:43