Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<pre><code>// try this way class CreateTrip extends AsyncTask { ProgressDialog pDialog; /** * Before Sttarting Background thread Show Progress Dialog */ @Override protected void onPreExecute() { super.onPreExecute(); pDialog = new ProgressDialog(CreateTripActivity.this); pDialog.setMessage("Creating Trip..."); pDialog.setIndeterminate(false); pDialog.setCancelable(true); pDialog.show(); } /** * Creating Trip */ protected String doInBackground(String... args) { String plate = inputPlate.getText().toString(); String customer = inputCustomer.getText().toString(); String area = inputArea.getText().toString(); String driver = inputDriver.getText().toString(); //Building parameters List&lt;NameValuePair&gt; params = new ArrayList&lt;NameValuePair&gt;(); params.add(new BasicNameValuePair("plate", plate)); params.add(new BasicNameValuePair("customer", customer)); params.add(new BasicNameValuePair("area", area)); params.add(new BasicNameValuePair("driver", driver)); //getting JSON Object // Note that create trip url accepts post method JSONObject json = jsonParser.makeHttpRequest(url_create_trip, "POST", params); // check log cat for response Log.d("Create Response", json.toString()); // check for success tag try{ int success = json.getInt(TAG_SUCCESS); if (success == 1){ // success to create trip return "1"; }else { return "0"; // failed to create trip } } catch (JSONException e){ e.printStackTrace(); } return null; } /** * After Completing background task Dismiss the progress Dialog */ protected void onPostExecute(String result) { // dismiss the dialog once done pDialog.dismiss(); if(result!=null &amp;&amp; result.equals("1")){ // success to create trip Intent i = new Intent(getApplicationContext(), CreateTripActivity.class); startActivity(i); finish(); }else{ // failed to create trip } } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload