Hello I am creating an android app where i want to know how to send http request using textView elements .
I have created a for whose summery has been displayed in another activity on textView which is non editable.
I have edited the following code and added the http request code which is ok now and now i want to known that i have to add the parameter such as the name, type and action i have gone through some examples but its getting me confused i am not getting it how actually i am apply those codes here
added http request code are as follows
public void sendData(){
nameText =(TextView)findViewById(R.id.content);
viewDateText =(TextView)findViewById(R.id.showDate);
viewEmailText=(TextView)findViewById(R.id.showEmail);
viewMobileText=(TextView)findViewById(R.id.showMobileNumber);
viewTotalAdultText = (TextView)findViewById(R.id.showTotalAdults);
ViewTotalChildren =(TextView)findViewById(R.id.showTotalChildrens);
viewChildAge =(TextView)findViewById(R.id.showChildrensAge);
viewTotalRoomsText =(TextView)findViewById(R.id.showTotalRooms);
viewDepartureText =(TextView)findViewById(R.id.showDepartureCity);
viewDeatinationText =(TextView)findViewById(R.id.showDestination);
viewDaysText =(TextView)findViewById(R.id.showTotalDays);
viewBudgetText =(TextView)findViewById(R.id.showBudget);
viewPreferHotelText =(TextView)findViewById(R.id.showHotelPreferance);
viewAirticketText =(TextView)findViewById(R.id.showAirticketRequired);
viewIntercityText = (TextView)findViewById(R.id.showIntercityTravel);
viewTravelTypeText = (TextView)findViewById(R.id.showTraveType);
viewMealText =(TextView)findViewById(R.id.showMealPlan);
viewInfoText = (TextView)findViewById(R.id.showAdditionalInfo);
nameText.getText().toString();
viewDateText.getText().toString();
viewEmailText.getText().toString();
viewMobileText.getText().toString();
viewTotalAdultText.getText().toString();
ViewTotalChildren.getText().toString();
viewChildAge.getText().toString();
viewTotalRoomsText.getText().toString();
viewDepartureText.getText().toString();
viewDeatinationText.getText().toString();
viewDaysText.getText().toString();
viewBudgetText.getText().toString();
viewPreferHotelText.getText().toString();
viewAirticketText.getText().toString();
viewIntercityText.getText().toString();
viewTravelTypeText.getText().toString();
viewMealText.getText().toString();
viewInfoText.getText().toString();
submitData.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
HttpClient httpclient = new DefaultHttpClient();
HttpPost post = new HttpPost("http://routern.com/EldestinoAction");
String json = "";
try{
JSONObject jsonObject = new JSONObject();
jsonObject.put("nameText",nameText);
jsonObject.put("date",viewDateText);
jsonObject.put("Email",viewEmailText);
jsonObject.put("mobile",viewMobileText);
jsonObject.put("Totaladult",viewTotalAdultText);
jsonObject.put("totalchildren",ViewTotalChildren);
jsonObject.put("childrenAge",viewChildAge);
jsonObject.put("hotelRooms",viewTotalRoomsText);
jsonObject.put("departure",viewDepartureText);
jsonObject.put("destination",viewDeatinationText);
jsonObject.put("days",viewDaysText);
jsonObject.put("budget",viewBudgetText);
jsonObject.put("preferhotel",viewPreferHotelText);
jsonObject.put("flight",viewAirticketText);
jsonObject.put("intercity",viewIntercityText);
jsonObject.put("travelType",viewTravelTypeText);
jsonObject.put("meal",viewMealText);
jsonObject.put("info",viewInfoText);
json = jsonObject.toString();
StringEntity se = new StringEntity(json);
post.setEntity(se);
post.setHeader("Accept", "application/json");
post.setHeader("Content-type", "application/json");
httpclient.execute(post);
}catch (Exception e){
e.printStackTrace();
}
}
});
}
i want to known that i have to add the parameter such as the name, type and action i have gone through some examples but its getting me confused i am not getting it how actually i am apply those codes here