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. Incoming Call dari Telkomsel Nomernya Aneh

Saya pengguna IM3, belakangan ini kalo dapet telepon dari Simpati atau AS
pasti nomernya aneh, ada 0 setelah kode negara. Jadi +62081xxxx atau
+620852xxxx. Akibatnya caller ID-nya gak muncul dan nomernya gak bisa
langsung ditelpon/sms balik... Error kalo dicoba ditelpon. Ada yang ngalamin
hal yang sama?

Eh, ini OOT gak yah? HH-nya pake Android sih. *maksa

-- 
"

2. Displaying Equations on Android

I am currently working on an application that is essentially an
equation "cheat sheet." I want to make the equations look good when
they are displayed, so I am thinking of using MathML, but I don't know
how I would implement this and include everything in a packaged
application. Any advice on how to do this? Or other suggestions for
displaying equations on Android?

Thanks,

Sam

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

3. Setting up keylayout

4. Help on creating a web service for an android application

5. fastboot on pandaboard

6. Please tell me how to configure Proxy in Android (Nexus S)

7. Auto-Complete/AutoSuggestion Dictionary