Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to send 5 strings from android app to website(local host)
    text
    copied!<p>i have taken help from few sites and developed a code for sending data from app to website . but this code is giving error . help me to send the 5 from my application form to website.</p> <p>public class MainActivityServer extends Activity { private ProgressDialog pDialog;</p> <pre><code>JSONParser jsonParser = new JSONParser(); Button send1; TextView name; TextView number; TextView email; TextView suggestion; // url to create new product private static String url_create_product = "http://api.androidhive.info/android_connect/create_product.php"; // JSON Node names private static final String TAG_SUCCESS = "success"; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main_activity_server); send1 = (Button)findViewById(R.id.Send); name= (EditText)findViewById(R.id.T1); number= (EditText)findViewById(R.id.T2); email= (EditText)findViewById(R.id.T3); suggestion= (EditText)findViewById(R.id.T4); send1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { // creating new product in background thread new CreateNewProduct().execute(); } }); } public class CreateNewProduct extends AsyncTask&lt;String, String, String&gt;{ protected String doInBackground(String... args) { String name = name.getText().toString(); String number = number.getText().toString(); String email = email.getText().toString(); String suggestion = suggestion.getText().toString(); List&lt;NameValuePair&gt; params = new ArrayList&lt;NameValuePair&gt;(); params.add(new BasicNameValuePair("name", name)); params.add(new BasicNameValuePair("price", number)); params.add(new BasicNameValuePair("description", email)); params.add(new BasicNameValuePair("description", suggestion)); // getting JSON Object // Note that create product url accepts POST method JSONObject json = jsonParser.makeHttpRequest(url_create_product, "POST", params); // check log cat fro response Log.d("Create Response", json.toString()); // check for success tag try { int success = json.getInt(TAG_SUCCESS); if (success == 1) { // successfully created product Intent i = new Intent(getApplicationContext(), AllProductsActivity.class); startActivity(i); // closing this screen finish(); } else { // failed to create product } } catch (JSONException e) { e.printStackTrace(); } return null; } /** * After completing background task Dismiss the progress dialog * **/ //end postData() public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.main_activity_server, menu); return true; } }} </code></pre> <p><img src="https://i.stack.imgur.com/RuRl0.png" alt="enter image description here"></p>
 

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