0

I'm trying to request for HTTP but it's dying on me on

HttpResponse httpResponse = httpClient.execute(httpGet);

Below is my code...

public JSONObject getJSONFromUrl(String url) {
    // HTTP Request
    try {
        // defaultHttpClient
        System.out.println("CRAZY1");
        HttpClient httpClient = new DefaultHttpClient();
        System.out.println("CRAZY2");
        HttpGet httpGet = new HttpGet(url);
        System.out.println("CRAZY3");

        System.out.println("CRAZY4");
        HttpResponse httpResponse = httpClient.execute(httpGet);
        System.out.println("CRAZY5");
        HttpEntity httpEntity = httpResponse.getEntity();
        System.out.println("CRAZY6");
        is = httpEntity.getContent();

    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    } catch (ClientProtocolException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

It's telling me thread is exiting with uncaught exception. I do have permissions enabled in the manifest. What could be the problem?

Mike
  • 826
  • 11
  • 31
  • The answer is probably here: [http://stackoverflow.com/questions/8706464/defaulthttpclient-to-androidhttpclient][1] [1]: http://stackoverflow.com/questions/8706464/defaulthttpclient-to-androidhttpclient – Bron Davies Feb 08 '13 at 22:37
  • I don't believe that's the case, because my build target is for 2.2 supporting min android version 2.2 – Mike Feb 08 '13 at 22:50
  • did you try to make a request to onCreate method? – DevfaR Feb 09 '13 at 00:39
  • Actually the problem was solved from one of the links i had to do a supresslint however but it works now – Mike Feb 09 '13 at 00:59

1 Answers1

0

Make sure that your URL includes http:// or else the constructor of HttpGet will throw a IllegalArgumentException.

user2055996
  • 1,545
  • 1
  • 11
  • 9