Http Connection

Discussion in 'Application Development' started by Nagendra1020, Apr 5, 2010.

  1. Nagendra1020

    Nagendra1020 New Member
    5

    Apr 5, 2010
    1
    0
    5
    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
    16

    Aug 10, 2008
    23
    7
    16
    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...