简体   繁体   中英

Asynctask get percentage of the progress in java

I have a AsyncTask that is unzipping files. Is it possible to get the percentage of the progress of the AsyncTask to show it in a horizontal ProgressBar ?

Override onProgressUpdate in your AsyncTask . Then call publishProgress from within the background thread. onProgressUpdate will be invoked on the UI thread with the parameter from publishProgress .

You determine the type of the progress parameter with the second type argument in AsyncTask .

AsyncTask has method onProgressUpdate(Integer...) that you can call each iteration for example or each time a progress is done during doInBackground() by calling publishProgress().

Refer to the doc for more details

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM