I'm tyring to consume a REST Web Service which returns a JSON Dictionary but the app crashes when I call
HttpResponse resp = httpClient.execute(post);
This is my code:
System.out.println("onClick!!!");
        HttpClient httpClient = new DefaultHttpClient();
        HttpPost post = new HttpPost("http://applocalize.com.br/rest/rest.php");
        post.setHeader("content-type", "application/json; charset=UTF-8");
        post.setHeader("Accept", "application/json");
        //Construimos el objeto cliente en formato JSON
        JSONObject dato = new JSONObject();
        try {
            dato.put("pg","categorias");
            dato.put("serv", "buscar");
            dato.put("dt_atualizacao", "");
            StringEntity entity = new StringEntity(dato.toString());
            post.setEntity(entity);
            HttpResponse resp = httpClient.execute(post);
            String respStr = EntityUtils.toString(resp.getEntity());
            System.out.println("OKAY!");
        } catch (ClientProtocolException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }
LOGCAT:
 28517-28517/com.allapps.localizeapp E/AndroidRuntime﹕ FATAL EXCEPTION: main
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.allapps.localizeapp/com.allapps.localizeapp.MapsActivity}: android.os.NetworkOnMainThreadException
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2252)
            at 
 
     
     
     
    