Bonjour Je crée une application Android où je veux savoir comment envoyer une requête http en utilisant des éléments textView.Comment envoyer une requête http en utilisant les éléments textView
J'ai créé un objet pour lequel l'été a été affiché dans une autre activité sur textView qui n'est pas éditable.
J'ai édité le code suivant et ajouté le code de requête http qui est correct maintenant et maintenant je veux savoir que je dois ajouter le paramètre tel que le nom, le type et l'action que j'ai traversé quelques exemples mais moi confus, je ne reçois pas ce comment en fait je suis appliquer ces codes ici
ajouté le code de requête HTTP sont les suivantes
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();
}
}
});
}
je veux savoir que je dois ajouter le paramètre tel que le nom, le type et l'action que je suis allé à travers quelques exemples, mais son me confondre je ne comprends pas comment en fait je suis appliquer ces codes ici
Et donc ce que vous avez essayé ou recherché pour la demande Http. Avez-vous vu [HttpUrlConnection] (https://developer.android.com/reference/java/net/HttpURLConnection.html). Vous avez la même question ici créé il y a 18 heures: [i-want-to-get-information-about-read-data-from-textview] (http://stackoverflow.com/questions/38252826/i- want-to-get-information-about-read-read-data-from-textview). Désolé mais je vais vous donner un point négatif parce que vous n'avez pas encore cherché quelque chose.Si vous allez google et recherchez ** android comment faire une demande http ** vous obtiendrez tant d'exemples. –
J'ai cherché monsieur sans chercher je ne posterai pas ici – Moulick
okey alors pourquoi vous créez même question que vous pouvez éditer votre question précédente ce que vous avez essayé et quels guides vous jetez un coup d'oeil. Je le dis pour vous parce que vous obtenez des points négatifs. –