我在一个应该连接到 servlet 的 android 应用程序中有一个活动。我有两个 EditText 字段并通过 editText_name.getText().toString 方法获取两个输入。但是该应用程序无法捕获输入并将其打印在Log.My 代码片段如下
public class ServletActivity extends Activity {
Button button;
TextView outputText;
//public String URL = "http://10.0.2.2:8080/MyHL7Server /getPatientDetails?patientID";
public String PatientDataURL = "http://192.168.161.129:8080/MyHL7Server/getPatientDetails?patientID";
public String SensorListURL="http://192.168.161.129:8080/MyHL7Server/getSensorDetails?CenterID";
public String PatientInfo=new String();
public String SensorList=new String();
public String PatientIdInput=new String();
public String CenterIdInput=new String();
private ProgressDialog progressMessage;
int patientDataFlag,sensorDataFlag=0;
EditText PatientIdInputField;
EditText CenterIdInputField;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_servlet);
//final Button ConnectServerButton=(Button)findViewById(R.id.button2);
button = (Button) findViewById(R.id.button);
outputText = (TextView) findViewById(R.id.textView3);
PatientIdInputField=(EditText)findViewById(R.id.editText1);
CenterIdInputField=(EditText)findViewById(R.id.editText2);
PatientIdInput=PatientIdInputField.getText().toString();
CenterIdInput=CenterIdInputField.getText().toString();
Log.e("PatientIdInput is",PatientIdInput);
Log.e("CenterIdInput is",CenterIdInput);
System.out.println("Inside Servlet Activity");
Log.e("Testing","Servlet Activity");
;
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Log.e("Patient Id Input",PatientIdInput);
Log.e("CenterId Input",CenterIdInput);
PatientDataURL.concat("=").concat(PatientIdInput);
Log.e("Debug PatientDataURL created",PatientDataURL);
Log.e("Debug","Calling GetPatientDataTask");
GetPatientDataTask patientTask = new GetPatientDataTask();
patientTask.execute(new String[] { PatientDataURL });
Log.e("PatientData",PatientInfo);
Toast.makeText(getApplicationContext(),
"Patient data is : "+PatientInfo, Toast.LENGTH_LONG).show();
System.out.println("Patient Data Obtained "+PatientInfo);
}
});
}
该应用程序能够通过 AsyncTask 连接到 servlet。但我担心即使我提供一些输入,用户输入字段仍然为空。
任何人都可以对这个问题有所了解吗?我必须更改我的 AndroidManifest.xml 文件中的任何内容吗???
任何帮助将不胜感激。