John
John

Reputation: 961

Showing progressing progressbar while compressing android

I created an app in android that enables the user to compress/decompress a file. I need to show a ProgressDialog to show the progress while compressing/decompressing a file. I know how to do the ProgressDialog, but I do not know how will I display the current progress or what will I put inside the publishProgress(code here). My problem is similar to this one:

Download a file with Android, and showing the progress in a ProgressDialog

But the link refers for downloading a file but what I need is for compressing/decompressing file. Thanks!

Upvotes: 1

Views: 764

Answers (1)

Jack Satriano
Jack Satriano

Reputation: 2029

Use a custom AsyncTask class. aka private class MySync extends AsyncTask {

  1. onPreExecute() , set up the ProgressDialog, set your max value setMax()

  2. doInBackGround(...) , compress/decompress, set the current progress setProgress()

  3. onPostExecute() , end the ProgressDialog (.dismiss())

I would need to see your code to determine a way to quantify your progress.

Upvotes: 1

Related Questions