Enter the user name and password on the logon page. After Successful Logon, the system jumps to the homepage. If the logon fails, an error message is displayed. When passing parameters, use the List of BasicNameValuePair as httpPost. setEntity. You cannot use HttpParams. [Java] userName = (EditText) this. findViewById (R. id. editTextUserName); password = (EditText) this. findViewById (R. id. editTextPassword); errorMsg = (TextView) this. findViewById (R. id. textViewLoginMsg); Button loginBtn = (Button) this. findViewById (R. id. btnLogin); loginBtn. setOnClickListener (new OnClickListener () {@ Override public void onClick (View arg0) {String result;/* Send part */try {HttpClient ht TpClient = new DefaultHttpClient (); String address = strUrl; HttpPost httpPost = new HttpPost (address); List <BasicNameValuePair> params = new parameter List <BasicNameValuePair> (); params. add (new BasicNameValuePair ("username", userName. getText (). toString (); params. add (new BasicNameValuePair ("password", password. getText (). toString (); httpPost. setEntity (new UrlEncodedFormEntity (params, "UTF-8"); // set Enter HttpResponse httpResponse = httpClient.exe cute (httpPost) in the POST Entity parameter;/* receive */if (httpResponse. getStatusLine (). getStatusCode () = 200) {result = EntityUtils. toString (httpResponse. getEntity ();/* json text parsing */JSONTokener jsonParser = new JSONTokener (result); JSONObject jsonResult = (JSONObject) jsonParser. nextValue (); String status = jsonResult. getString ("loginStatus"); String outMessage = j SonResult. getString ("outMessage"); if (status. equals ("true") {Intent I = new Intent (LoginActivity. this, MainActivity. class); I. putExtra ("username", outMessage); startActivityForResult (I, FIRST_REQUEST_CODE);} else {errorMsg. setVisibility (View. VISIBLE); errorMsg. setText (outMessage) ;}} else {errorMsg. setVisibility (View. VISIBLE); errorMsg. setText ("network connection problem. CODE: "+ httpResponse. getStatusLine (). getStatusCode ();} catch (JSONException e) {e. printStackTrace ();} catch (UnsupportedEncodingException e) {e. printStackTrace ();} catch (ClientProtocolException e) {e. printStackTrace ();} catch (IOException e) {e. printStackTrace ();}}});