I’ve written a speedlimit app that loads data from a set of tiled xml files representing 0.05 sided degree maps.
At the moment, the app checks if I’ve moved into a new square (using OnLocationChanged) and if so loads in the data for it and the surrounding other 8 tiles.(has a bit of a sanity check and only loads data for new tiles so tends to just load in another 3 tiles worth of data)
Anyway, it currently does this on the UI thread and so there is a noticeable pause when moving into new square and I’d like to shift it to background using Asynctask (It also loads in bitmap maps for display purposes and I’ve already moved that code into an Asynctask so I know how to do that bit)
My problem is to do with checking the arrays (actually using ArrayLists) used for the speed limits while the Asynctask is possibly adding (and in future version – subtracting) to them in the background.
I was wondering if there was a “professional” 🙂 way of dealing with this sort of situation.
A synchronized access should be dealing with all problems of concurrency accessing the ArrayList. Just use
Both in your AsyncTask and your UI.
Good resource is the stackoverflow search