network + ui updates, asynctask vs handler
<p>I have a map that i want to update from a separate thread. Im having some issues when i try to update the UI from my class that extends asynctask. And when i move the code to a handler in the main thread i get <code>NetworkOnMainThreadException</code>. Below is my asynctask. Is there any way to modify it to make it work?</p>

<pre><code>@Override
    protected Integer doInBackground(Void... params) {

        try {

            HttpClient httpclient = new DefaultHttpClient();
            HttpPost httppost = new HttpPost("http://83.xx.xx:8080/android/service.php");

            List&lt;NameValuePair&gt; nameValuePairs = new ArrayList&lt;NameValuePair&gt;(2);
            nameValuePairs.add(new BasicNameValuePair("action", "getusers"));
            nameValuePairs.add(new BasicNameValuePair("interval", Integer.toString(interval)));

            httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));

            HttpResponse response = httpclient.execute(httppost);

            String jsonString = EntityUtils.toString(response.getEntity());

            Gson gson = new GsonBuilder().create();

            Type listType = new TypeToken&lt;ArrayList&lt;User&gt;&gt;() {}.getType();
            ArrayList&lt;User&gt; userList = gson.fromJson(jsonString, listType);

            ((GoogleMapsActivity) activity).removeOverlayItems();

            for(User user : userList ){

                ((GoogleMapsActivity) activity).addOverlayItem(Double.parseDouble(user.last_lat), Double.parseDouble(user.last_lng), user.bluetooth_name, "test desc");
            }


            return 1;

        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
</code></pre>
