No se puede publicar el progreso de la tarea asincrónica en el bucle while de fondo: Android

Quiero actualizar el progreso de descarga del cuadro de diálogo desde doInBackground.
Estoy imprimiendo el registro y publicando el progreso.
Ninguno de ellos está trabajando.

Actualiza el diálogo al final e imprime todos los valores de registro a la vez al final

private class DownloadEReport extends AsyncTask<String, Void, Void> {
    int progress = 0;

    protected void onPreExecute() {
        mProgressDialog = new ProgressDialog(EReport.this);
        mProgressDialog.setTitle("Downloads");
        mProgressDialog.setMessage("Downloading, Please Wait!");
        mProgressDialog.setIndeterminate(false);
        mProgressDialog.setMax(100);
        mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
        mProgressDialog.setCancelable(false);
        mProgressDialog.show();
    }

    @Override
    protected void onProgressUpdate(Void... values) {
        super.onProgressUpdate(values);
        mProgressDialog.setProgress(progress);
    }



    @Override
    protected Void doInBackground(String... strings) {

        String mUrl = strings[0];
        String json = "";
        int count;
        try {
            URL url = new URL(mUrl);
            URLConnection conection = url.openConnection();
            conection.connect();
            // getting file length
            int lenghtOfFile = conection.getContentLength();

            // input stream to read file - with 8k buffer
            InputStream input = new BufferedInputStream(url.openStream(), 8192);

            // Output stream to write file
            OutputStream output = new FileOutputStream("/sdcard/downloadedfile.txt");

            byte data[] = new byte[1024];
            long total = 0;
            while ((count = input.read(data)) != -1) {
                total += count;
                // writing data to file
                output.write(data, 0, count);

                // publishing the progress....
                // After this onProgressUpdate will be called
                Log.e("JSON Download Progress", "" + (int) ((total * 100) / lenghtOfFile));
                progress = (int) (total * 100 / lenghtOfFile);
                publishProgress();
            }

            // flushing output
            output.flush();
            // closing streams
            output.close();
            input.close();

        } catch (Exception e) {
            Log.e("Error: ", e.getMessage());
        }

        return null;
    }

    @Override
    protected void onPostExecute(Void aVoid) {
        super.onPostExecute(aVoid);
        mProgressDialog.dismiss();
    }
}

Respuestas a la pregunta(1)

Su respuesta a la pregunta