How to perform a HTTP request ?

by binklee » Sun, 15 Mar 2009 06:47:14 GMT


Sponsored Links
 Hi,
I'm trying to perform a HTTP request and to read the answer.

My first idea was to import java.net.*; and to use :

URL url = new URL(myUrl);
String answer = (String)url.getContent(); // !!!  produce an error in
Android !


After some research in the group, I am confused on what should I do.
Should I use :

org.apache.http                                         or
org.apache.commons.httpclient.HttpClient         // <--- is it
officially supported by android?

and how to implement it?

Thank you for your help.
Deniz
--~--~---------~--~----~------------~-------~--~----~



How to perform a HTTP request ?

by Mark Murphy » Sun, 15 Mar 2009 08:11:55 GMT


 


Try this:

 http://www.exampledepot.com/egs/java.net/ReadFromURL.html 

Also, make sure you have the INTERNET permission declared in your
AndroidManifest.xml file.


Android currently incorporates org.apache.http.*. Previously, it used an
earlier version of the Apache code which was in the
org.apache.commons.httpclient.* namespace.

Examples of using org.apache.http.* can be found at:

 http://hc.apache.org/httpcomponents-client/examples.html 

-- 
Mark Murphy (a Commons Guy)
 http://commonsware.com 
Warescription: Three Android Books, Plus Updates, $35/Year

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


Sponsored Links


Other Threads

1. On ExpandableListViews Again

Hi All,

So I have this issue with ExpandableListViews I don't quite
understand. I'm having the exact issue as this person almost a year
ago but I'm seeing the solution is not really clear:

2. CPU Clock History

So I want something that can keep track of CPU clock speed over a
period of time. Specifically when the screen was off. I asked around
and no really had a good solution.

Being new to android but old to linux, I figured I could just make a
script that would check /proc/cpuinfo and every couple of seconds and
save it to a text file. Simple....I thought.

CPUinfo on my phone (HTC Incredible) doesn't show processor speed.

Anyone know of a way to accomplish what I want? Maybe there is an app
out already that will do what I wish, but I haven't been able to find
one.

-- 

3. disable hard Search button while contextmenu is on.

4. WebView - numeric keyboard from html

5. Android: Multiple POST on the same connection

6. ClassNotFoundException on Market developer console

7. How to have a Service, un-killed by any task killer