public class MainActivity extends ActionBarActivity { EditText e1, e2; Button b1; HttpClient client; String url = "http://localhost:52455/bloodservice/Service.svc"; JSONObject json; final Context context = this; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); b1 = (Button) findViewById(R.id.button); b1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { e1 = (EditText) findViewById(R.id.editText); e2 = (EditText) findViewById(R.id.editText2); String t1 = e1.getText().toString(); String t2 = e2.getText().toString(); HttpClient client = new DefaultHttpClient(); HttpResponse response; JSONObject json = new JSONObject(); HttpPost post = new HttpPost(url); json.put("userName",t1); //HERE IM GETTING ERROR UNHANDLED EXCEPTION org.json,JSONException json.put("userPassword", t2);//HERE IM GETTING ERROR UNHANDLED EXCEPTION org.json,JSONException StringEntity se=null; try { se = new StringEntity(json.toString()); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } se.setContentType("application/json;charset=UTF-8"); se.setContentType(new BasicHeader(HTTP.CONTENT_TYPE,"application/json")); post.setEntity(se); response = Client.execute(post);//HERE IM GETTING ERROR UNHANDLED EXCEPTION org.apache.http.client.ClientProtocolException.
json.Add("userName",t1); json.Add("userPassword", t2);
try { json.put("userName", t1); json.put("userPassword", t2); }catch (JSONException e) { e.printStackTrace(); }
<pre lang="java">response = Client.execute(post);//HERE IM GETTING ERROR UNHANDLED EXCEPTION org.apache.http.client.ClientProtocolException.
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)