0

In my application it need to unzip a zipped folder.In my code it is unable to add a progressbar with it.So i googled and found an answered question in stackoverflow Progress Bar with unzipping of file.

(copied)

private class Decompress extends AsyncTask<Void, Integer, Integer> {

   private String _zipFile;   
   private String _location;
   private int per = 0;

    public Decompress(String zipFile, String location) {
            _zipFile = zipFile;     
            _location = location;      
            _dirChecker("");   
            }    

     protected Integer doInBackground() {
         try  {       
            ZipFile zip = new ZipFile(_zipFile);
            bar.setMax(zip.size());
            FileInputStream fin = new FileInputStream(_zipFile);       
            ZipInputStream zin = new ZipInputStream(fin);
            ZipEntry ze = null;       
            while ((ze = zin.getNextEntry()) != null) {

                Log.v("Decompress", "Unzipping " + ze.getName());          
                if(ze.isDirectory()) {           
                    _dirChecker(ze.getName());         
                    } else {      
                // Here I am doing the update of my progress bar

                        per++;
                        publishProgress(per);

                        FileOutputStream fout = new FileOutputStream(_location +ze.getName());           
                        for (int c = zin.read(); c != -1; c = zin.read()) {  

                            fout.write(c);           
                            }            
                        zin.closeEntry();          
                        fout.close();         
                        }                
                }       
            zin.close();    
            } catch(Exception e) {       
                Log.e("Decompress", "unzip", e);    
                }    
        }    


         }
         return totalSize;
     }

     protected void onProgressUpdate(Integer... progress) {
         bar.setProgress(per); //Since it's an inner class, Bar should be able to be called directly
     }

     protected void onPostExecute(Integer... result) {
         Log.i("Completed. Total size: "+result);
     }
    }

When i tried to execute it gives an error Error:(152, 9) error

: FileexplorerActivity.Decompress is not abstract and does not override abstract method doInBackground(Void...) in AsyncTask

How can i resolve this .

Community
  • 1
  • 1
  • 1
    http://stackoverflow.com/questions/27896786/mainactivity-downloadwebpagetask-is-not-abstract-and-does-not-override-abstract – IntelliJ Amiya Jan 14 '16 at 06:32

2 Answers2

0

There is no doBackground() without parameters in Asynctask

protected abstract Result doInBackground (Params... params)

You should include parameters in doBackground().

Shriram
  • 4,343
  • 8
  • 37
  • 64
0

Include parameters in doInBackground():

protected Integer doInBackground(Void... voids)
{
    ....
    return totalSize;
}
Faraz
  • 2,144
  • 1
  • 18
  • 28