Unable to Update UI using AsyncTask in Android : I have a `MapActivity` in my android application and I want to draw a route from source to destination followed by drawing `polyline` along the path found. I am showing a `progressDialog` while `polyline` is drawn along the path.

I think drawing polyline is a heavy task as it caused `progressDialog` to stop spinning. So I put `drawPolyline` functionality inside an `AsyncTask`.

But the problem I am facing now is I am not getting updated screen but suddenly the `MapActivity` screen blinks and disappear and I see the MainActivity now.

Why is it happening?
I want to know whether or not updating UI in AsyncTask is conceptually correct? If yes, how can we go about doing it?


**Note:** I have checked AsyncTask functionality by putting breakPoints. It is working as expected but drawPolyline causes error.
Also drawPolyline has no problem as it works fine when called without AsyncTask.

Any kind of suggestions will be greatly appreciated.

Thanks!