private class DownloadFilesTask extends AsyncTask {
protected Long doInBackground(URL... urls) { // on some background thread
for (int i = 0; i < count; i++) {
totalSize += Downloader.downloadFile(urls[i]);
publishProgress((int) ((i / (float) count) * 100));
protected void onProgressUpdate(Integer... progress) { // on UI thread!
setProgressPercent(progress[0]);
protected void onPostExecute(Long result) { // on UI thread!
showDialog("Downloaded " + result + " bytes");
new DownloadFilesTask().execute(url1, url2, url3); // call from UI thread!
private boolean handleWebSearchRequest(final ContentResolver cr) {
protected Void doInBackground(Void... unused) {
Browser.updateVisitedHistory(cr, newUrl, false);
Browser.addSearchUrl(cr, newUrl);