Http Connection


Last Updated:

  1. Nagendra1020

    Nagendra1020 New Member This Topic's Starter

    Joined:
    Apr 5, 2010
    Messages:
    1
    Likes Received:
    0
    Hi All,
    I am new in android.
    I written small program that will connect to server but, it my app getting connect can anybody tell me what is problem.

    Code is :

    public void http()
    {
    try
    {
    URI uri = new URI("http://localhost:8080/TestApp/");
    Log.v(TAG,uri.toString());
    HttpGet get = new HttpGet(uri);
    HttpClient client = new DefaultHttpClient();
    HttpResponse response = client.execute(get);
    Log.v(TAG,response.toString());
    }
    catch (Exception e) {
    // TODO: handle exception
    }
     

    Advertisement
  2. jon21569

    jon21569 Member

    Joined:
    Aug 10, 2008
    Messages:
    23
    Likes Received:
    7
    Here is a sample app that connects to a server. Enter your URL in the where it says "ENTER URL HERE" in the code.
     

    Attached Files:

Share This Page

Loading...