bonjour

impossible de trouver la solution sur le net

dans une tache asynchrone AsyncTask
dans la méthode doInBackground je fais appel à publishProgress() pour mettre à jour dans onProgressUpdate() et ca me renvoi le message comme quoi je dois créer la méthode publishProgress !!!
j'utilise un code tout à fait standard pour télécharger un fichier
quelqu'un peut il me dire d'où ca vient

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
 
    protected class DownloadFileTask extends AsyncTask<String, Void, String> {
        String urlFichierServeur;
        String pathFichier;
        private ProgressDialog pDialog;
        private Context context = null;
 
        public DownloadFileTask(String urlFichierServeur, String pathFichier) {
            this.urlFichierServeur = urlFichierServeur;
            this.pathFichier = pathFichier;
            pDialog = new ProgressDialog(context);
        }
        @Override
        protected void onPreExecute() {
            super.onPreExecute();
            pDialog.setMessage("téléchargement du fichier patientez...");
            pDialog.setIndeterminate(false);
            pDialog.setMax(100);
            pDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
            pDialog.setCancelable(false);
            pDialog.show();
        }
        @Override
        protected String doInBackground(String... params) {
            int count;
            try {
                URL url = new URL(urlFichierServeur);
                URLConnection connection = url.openConnection();
                connection.connect();
                int lenghtOfFile = connection.getContentLength();
 
                InputStream input = new BufferedInputStream(url.openStream(), 8192);
                File file = new File(pathFichier);
                OutputStream output = new FileOutputStream(file);
 
                long total = 0;
                byte data[] = new byte[1024];
                while ((count = input.read(data)) != -1) {
                    total += count;
                    output.write(data, 0, count);
                    publishProgress((int) ((total * 100) / lenghtOfFile));
                }
 
                output.flush();
                output.close();
                input.close();
 
            } catch (Exception e) {
                //e.printStackTrace();
                return "erreur de téléchargement";
            }
            return "download_ok";
        }
        protected void onProgressUpdate(Integer... progress) {
            //super.onProgressUpdate(progress);
            //mTextView.setText(progress[0] + " %");
            this.pDialog.setProgress(progress[0]);
        }
        @Override
        protected void onPostExecute(String result) {
            pDialog.dismiss();
        }
    }