Android Async Task Progress Bar onProgressUpdate

前端 未结 3 947
广开言路
广开言路 2020-12-30 16:50

I am a new programmer. I have seen lots of tutorials but can\'t understand what is wrong. I am trying to create a ProgressBar from an Async Task. However it always crashes m

3条回答
  •  -上瘾入骨i
    2020-12-30 17:33

    Intervals.getApp().progressBar.setProgress(values[0]);
    

    There are two possibilities for the NullPointerException in this line of code:

    1. getApp() returns null
    2. progressBar is null

    In order to determine which is the cause, you need to split this into two separate lines:

    Intervals intervals = Intervales.getApp();
    intervals.progressBar.setProgress(values[0]);
    

    Now set a breakpoint at the first line, step over it, and determine if intervals is null or not.

提交回复
热议问题