0

I want to Maintain the SeekBar along with the File's Decompression (UnZip).

The SeekBar needs to Start with the UnZip of the File and gets Over when the Decompressing Process of the .zip file gets Finished.

Have Googled for this but couldn't find what I am looking for.

Thanks, DavidBrown

David Brown
  • 4,783
  • 17
  • 50
  • 75

1 Answers1

0

You can do something like this. Use AsyncTask for background process. Progress of decompression you can set to seekBar as below. Hope this helps.

class SampleTask extends AsyncTask<Void, Integer, String>
{
    private Context context = null;

    public SampleTask(Context context) 
    {
        this.context = context;         
    }

    @Override
    protected void onPreExecute() 
    {
        super.onPreExecute();
    }

    @Override
    protected String doInBackground(Void... params) 
    {
        try
        {
            //do file decompression here
               publishProgress(progress);
        }
        catch(Exception exception) 
        {
            exception.printStackTrace();
        }
        return null;
    }

    @Override
    protected void onProgressUpdate(Integer... values) 
    {
        super.onProgressUpdate(values);
        System.out.println(" --- onProgressUpdate --- "+values[0]);
        seekBar.setProgress(values[0]);
    }

    @Override
    protected void onCancelled() 
    {
        super.onCancelled();
        isTrue = false;
        sampleTask = null;
        System.out.println(" --- onCancelled --- "+isTrue);
    }

    @Override
    protected void onPostExecute(String result) 
    {
        super.onPostExecute(result);
    }       
}

Edit : Have a look at following links.

Unzip a zipped file on sd card in Android application

How to unzip files programmatically in Android?

Community
  • 1
  • 1
Braj
  • 2,164
  • 2
  • 26
  • 44