Problems with HttpClient, HttpGet and HttpResponse ...

by rustyventure » Tue, 09 Dec 2008 10:22:39 GMT


Sponsored Links
 Hi, everyone:

I'm just starting to play around with the Android SDK, but i haven't
developed any Java apps for a few years and my skills are a little
rusty ...

I'm trying some code that uses the HttpClient class. From what I've
seen from other online examples, the following code should work:

HttpClient httpclient = new DefaultHttpClient();
HttpGet httpget = new HttpGet(" http://www.google.com ");
HttpResponse response = httpclient.execute(httpget);

However, Eclipse won't let me debug this as httpclient.execute
(httpget) is underlined with an error: "Unhandled exception type
ClientProtocolException". Any ideas why I'm getting this error? Thanks
in advance!

--~--~---------~--~----~------------~-------~--~----~



Problems with HttpClient, HttpGet and HttpResponse ...

by rustyventure » Wed, 10 Dec 2008 03:49:14 GMT


 Looks like I answered my own question :)

I allowed Eclipse to auto correct my code, and it added a try - catch
routine:

HttpClient httpclient = new DefaultHttpClient();
        HttpGet httpget = new HttpGet(" http://www.google.com ");
        try {
                        HttpResponse response = httpclient.execute(httpget);
                } catch (ClientProtocolException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                } catch (IOException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                }

My code complies now, so I can go back to exploring :)





--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


Other Threads

1. FYI - Both GL and Canvas are locked to 30FPS on new phones.

There's a difference between "new phones" and "the HTC EVO 4G." It is
certainly not the goal of the Android team to ship devices locked at
30 FPS. Our target was, is and will be 60 FPS.



> 

2. android phone鈥檚 scroll ball, D-Pad not working

hi,

i have a Cliq and a MyTouch phone. i am writing a game that requires a
fire button. on the cliq, it's the center of the D-Pad, and on the
MyTouch, the scroll ball. i am handling the onKeyDown events via a
separate thread. it all works until i press the button too many times,
meaning the key down event is no longer fired off. if i press the D-
Pad down or scroll the ball down, then the fire button works again. i
can only guess that maybe the message queue within the OS is full,
therefore the fire button temporarily malfunctions. can someone help
me?

also, i have uploaded the game ("Attack Helicopter") to the market,
feel free to check it out and critique it.

thanks.

-- 

3. dynamic content of a ListPreference

4. Problem in programmatically installing a 3rd party App onto the SD card

5. Problem in programmatically installing a 3rd party App onto the SD card

6. Strange behavior when launching app from Market

7. Question about junky apps