tags:

views:

15

answers:

1

Hi folks,

i am developing android applicaiton disply user overlays on map.user values getting from webservices for disply overlays.when i tap on map and move it is calling draw method and connecting to webservices while connecting webservice and getting data my apps is struck

show force close error .how can i resolve this problem

A: 

You have to move all the code that is communicating into another thread. The best way to do this is to use a asyncTask. You have to override the doInBackground method and put all the code that does blocking calls to the network into this method. The asyncTask will do everything in this method in a separate thread. If you also override the onPostExecute you can use this method to update your view. The onPostExecute is executed in UI thread and is therefore allowed to do changes on the User Interface.

In general if you are running code that takes some time to be finished always put this code into a separate thread, make the UI display a progressbar and wait for the thread to finish. If your UI thread is doing heavy work and is not able to respond to user input in a certain amount of time android will mark you app as crashed and offer the user to destroy it.

Janusz