Posts

Showing posts with the label update ui

Basic structure of AsyncTask Class

private class DownloadFilesTask extends AsyncTask<URL, Integer, Long> {     protected Long doInBackground(URL... urls) {         while (true) {             // Do some work             publishProgress((int) ((i / (float) count) * 100));         }        return result;     }     protected void onProgressUpdate(Integer... progress) {         setProgressPercent(progress[0]);     }     protected void onPostExecute(Long result) {         showDialog(“Result is “ + result);     } } To execute, new DownloadFilesTask (). execute ( url1 , url2 , url3 ); To read more about async task refer android developer guide.