Note that there are some explanatory texts on larger screens.

plurals
  1. POIssue in httpost app stops
    text
    copied!<p>so, i have this code here: This doesn't really work , i get app has stopped, the issue is, before when i tried this at home it worked just fine...now it doesn't! I don't know what is wrong here, could someone please take a look and tell me? Thanks..</p> <pre><code>public class MainActivity extends Activity { EditText msgTextField; Button sendButton; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); //make message text field object msgTextField = (EditText) findViewById(R.id.msgTextField); //make button object sendButton = (Button) findViewById(R.id.sendButton); } public void send(View v) { //get message from message box String msg = msgTextField.getText().toString(); //check whether the msg empty or not if(msg.length()&gt;0) { HttpClient httpclient = new DefaultHttpClient(); HttpPost httppost = new HttpPost("http://192.168.10.28/app/app1.php"); try { List&lt;NameValuePair&gt; nameValuePairs = new ArrayList&lt;NameValuePair&gt;(2); nameValuePairs.add(new BasicNameValuePair("id", "01")); nameValuePairs.add(new BasicNameValuePair("message", msg)); httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs)); httpclient.execute(httppost); msgTextField.setText(""); //reset the message text field Toast.makeText(getBaseContext(),"Sent",Toast.LENGTH_SHORT).show(); } catch (ClientProtocolException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } else { //display message if text field is empty Toast.makeText(getBaseContext(),"All fields are required",Toast.LENGTH_SHORT).show(); } } } </code></pre> <p>Here i have the Manifes.xml</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.form" android:versionCode="1" android:versionName="1.0" &gt; &lt;uses-sdk android:minSdkVersion="8" android:targetSdkVersion="17" /&gt; &lt;uses-permission android:name="android.permission.INTERNET" /&gt; &lt;application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" &gt; &lt;activity android:name="com.example.form.MainActivity" android:label="@string/app_name" &gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.MAIN" /&gt; &lt;category android:name="android.intent.category.LAUNCHER" /&gt; &lt;/intent-filter&gt; &lt;/activity&gt; &lt;/application&gt; &lt;/manifest&gt; </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