Async Task An error occured while executing doInBackground()

前端 未结 3 1391
庸人自扰
庸人自扰 2020-12-17 17:30

From my previous question

I was getting NullPointor exception. So i have done some changes in my code and now progress bar is showing up but getting the below error

3条回答
  •  眼角桃花
    2020-12-17 17:35

    Can't create handler inside thread that has not called Looper.prepare()
    

    You are accessing something on the UI thread from inside doInBackground. And that's not allowed.

    *edit: I've seen everything. To me, what looks mostly unusual are those lines:

    updateWithNewLocation(location); // What does this do? Could you tell me?
    locationManager.requestLocationUpdates(provider, 2000, 10,
            locationListener); // I don't think this is it
    

    Try to move all those location update stuff into the onProgressUpdate. I'm blind here since I can't see your code, but I'm guessing it does something with the UI. Try this:

    @Override
    protected void onProgressUpdate(Location... locations) {
        super.onProgressUpdate(values);
        updateWithNewLocation(location);
    }
    

    But as I said, I'm not sure since I can't know what updateWithNewLocation does unless you post that code here.

提交回复
热议问题