I'm unable to call a servlet from my Android application

前端 未结 1 649
离开以前
离开以前 2021-01-21 04:05

This is my android application:

package org.me.sampleandroidservlet;

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
impo         


        
相关标签:
1条回答
  • 2021-01-21 04:45

    Your code is looks incomplete:

    try this snippet:

    String serverResponse =""; // it will hold the response returned by the server
    try
    {
        HttpClient http=new DefaultHttpClient();
        HttpGet httpget = new HttpGet(
             "http://10.0.2.2:8084/SampleWebUser/SampleUser?hello=hi");
        HttpResponse response = http.execute(httpget);        
    
       serverResponse = EntityUtils.toString(resEntity); // Server response
       /*
             Do your other stuff here.
       */ 
    }
    catch(Exception ex)
    {
        ex.printStackTrace();
    }
    
    0 讨论(0)
提交回复
热议问题