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. installing application on a netbook

do you need to do anything special to get an application to run on a
netbook?

my application, which installs and runs just fine on a phone with 1.6
will not install on a netbook.

when i go to install, it pops up a dialog that says --



Application not installed

MyApp could not be installed on this device.




tia.


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

2. Advice on Beta Release

SO i have an application that is doing pretty well on my dev. device,
and it is almost ready for prime time.

Trouble is I am only one man, so I would like to release the
application under a beta release to work out any prominent bugs with a
more strenuous workout.

So I was thinking;

* Just release the app through the Market and note in the description
and title that the app is in beta mode, and to use at own risk

* Round up a group of friendly strangers with android devices and
share a signed (short lifespan) package directly with them.

* push and pray - just release the app and hope the community will
overlook a few undocumented features (I would like to avoid this!)

Has anyone else taken a phased approach to releases? Any advice for a
first time publisher?

P.S. - My app will be free, and likely released as open source of
flavor, so I am not worried about losing profits.
--~--~---------~--~----~------------~-------~--~----~

3. Run the Previous Activity

4. Javascript drop down becomes text input on Android

5. Striking It Rich: Is There An App For That?

6. iPhone apss - a fair game?

7. how can i increase memory