0

I have an async task which is executed on file download, the progress update works quite fine for progress bar but it doesn't work (app crashes) if i use that values[0] for textview to display progress, i am not able to understand why..

@Override
protected void onProgressUpdate(Integer... values) {
    super.onProgressUpdate(values);
    Log.v("Progress ", Integer.toString(values[0]));
    pbar.setProgress(values[0]);
    // tmin and tmax are texview, on uncommenting app crashes.
    //tmin.setText((values[0].toString()));
    //tmax.setText((Integer.toString(lengthOfFile)));
}
Lukas Knuth
  • 25,449
  • 15
  • 83
  • 111
Programmer
  • 5,360
  • 10
  • 37
  • 61

2 Answers2

0

what is the exception that caused the crash? please look at the logcat view on eclipse .

if it's a null pointer exception , don't forget to set the value of the textViews (depends on what you did , but probably you need to use findViewById) before creating and calling the asyncTask .

android developer
  • 114,585
  • 152
  • 739
  • 1,270
0

This link gives you a batter code and good explanation after applying this code if does't work then you have to define length in your server side for that file.

Community
  • 1
  • 1
Arpit Patel
  • 7,212
  • 5
  • 56
  • 67