1

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!

Community
  • 1
  • 1
John
  • 941
  • 8
  • 17
  • 2
    you can start showing your dialog in PreExecution of Async task with ProgressDialog.show() and in doInBackground you can do your compressing and Dismiss your dialog in PostExecution. – rajpara Jun 28 '12 at 04:55
  • 3
    @AndroidCoader I think he is asking about how to use a bar style ProgressBar and specifically how to determine what percentage complete the compression/decompression is so that that value can be set to the progress bar. – FoamyGuy Jun 28 '12 at 05:08
  • Thanks Tim. Sorry I can't post my codes here its confidential. Can anyone please help me? – John Jun 28 '12 at 07:50
  • Did you get the solution for this ? – King of Masses Sep 05 '17 at 10:01

1 Answers1

1

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.

Jack Satriano
  • 1,999
  • 1
  • 13
  • 17