class BaseDatosAgregarPedido extends AsyncTask<String, String, String> { @Override protected void onPreExecute() { super.onPreExecute(); pDialog = new ProgressDialog(AgregarPedido.this); pDialog.setMessage("Agregando Pedido..."); pDialog.setIndeterminate(false); pDialog.setCancelable(true); pDialog.show(); } @Override protected String doInBackground(String... args) { // TODO Auto-generated method stub // Check for success tag int success; String username = descrip.getText().toString(); String password = num.getText().toString(); try { // Building Parameters List params = new ArrayList();
//nombre de los cuadros que deseas rellenar params.add(new BasicNameValuePair("Descripcion", username)); params.add(new BasicNameValuePair("idHabitacion", password)); Log.d("request!", "starting"); //Posting user data to script JSONObject json = jsonParser.makeHttpRequest( PEDIDO_URL, "POST", params); // full json response Log.d("Registering attempt", json.toString()); // json success element success = json.getInt(TAG_SUCCESS); if (success == 1) { Log.d("Pedido Created!", json.toString()); finish(); return json.getString(TAG_MESSAGE); }else{ Log.d("Pedido Failure!", json.getString(TAG_MESSAGE)); return json.getString(TAG_MESSAGE); } } catch (JSONException e) { e.printStackTrace(); } return null; } protected void onPostExecute(String file_url) { // dismiss the dialog once product deleted pDialog.dismiss(); if (file_url != null){ Toast.makeText(AgregarPedido.this, file_url, Toast.LENGTH_LONG).show(); } } }