Hi All,

     I am new in Android development world. I want to establish a
HttpConnection from my android phone.

I have used this following code in a separate class but experiencing a
null exception.


import java.io.*;
import java.net.*;



try
                {
                        URL url = new URL(MyURLSTR);
                        URLConnection conn = url.openConnection();
                        TRACKER++;
                        if(conn!=null)
                        {
                        if (!(conn instanceof HttpURLConnection)) throw new 
IOException
("Not an HTTP connection.");


                        httpConn = (HttpURLConnection) conn;

                        httpConn.setAllowUserInteraction(false);
                        httpConn.setConnectTimeout(10000);
                        httpConn.setReadTimeout(10000);
                        httpConn.setInstanceFollowRedirects(true);
                        httpConn.setRequestMethod("POST");

                        httpConn.connect();   //found exception at this line


                        response = httpConn.getResponseCode();

                                if (response == HttpURLConnection.HTTP_OK)
                                {
                                  some code
                              }
                     }
                    catch(Exception exc)
                     {

                     }


Can any one help me regurding this problem.

Or is there any other way to establish Httpconnection??

Thanxx

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to