PS:NOT tested on device/emulator...
this is get, but u can easily make it post.
//
//TEST METHODS
//
/**
* Method to download an image
*/
private Bitmap downloadImage(String URL)
{
Bitmap bitmap = null;
InputStream in = null;
try {
in = OpenHttpConnection(URL);
bitmap = BitmapFactory.decodeStream(in);
in.close();
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
return bitmap;
}
private InputStream OpenHttpConnection(String urlString) throws
IOException
{
InputStream in = null;
int response = -1;
URL url = new URL(urlString);
URLConnection conn = url.openConnection();
if (!(conn instanceof HttpURLConnection))
throw new IOException("Not an HTTP connection");
try{
HttpURLConnection httpConn = (HttpURLConnection) conn;
httpConn.setAllowUserInteraction(false);
httpConn.setInstanceFollowRedirects(true);
httpConn.setRequestMethod("GET");
httpConn.connect();
response = httpConn.getResponseCode();
if (response == HttpURLConnection.HTTP_OK) {
in = httpConn.getInputStream
();
}
}
catch (Exception ex)
{
throw new IOException("Error connecting");
}
return in;
}
On Jul 17, 6:52 am, Chris <[email protected]> wrote:
> How to create an HTTP request object of POST type in android? Which
> class need to be extend or what method need to implement? How to
> establish connection to a server?
> Actually i want to connect to a microsoft exchange server, and then i
> have to send a request to it using HTTP.
> I dont have any idea about this, any help will be highly apperciated.
>
> THANKS A LOT....
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---