What is HTTP? 1. hypertext Transfer Protocol is the most widely used network protocol on the Internet. HTTP is a standard for client and server requests and responses. The client is an end user and the server is a website. HTTP is the application layer communication protocol between the client browser or other applications and the Web server. How HTTP Works 1. establish a connection between the client and the server. after the connection is established, the client wants the server to send a request. 3. after receiving the request, the server sends the response information to the client. client and server disconnected Note: The fourth article here requires attention, that is, when the user sees the following interface, the client has been disconnected from the server. The following is a simple example of how to connect to the server and obtain data from the server. It is running: when a user clicks the button, the user sends a request to the server, the returned data is displayed in the textview below. The specific implementation code is as follows: [java] p <span style = "font-size: 18px; "> ublic class MainActivity extends Activity {private Button button; private TextView textView; private HttpResponse httpResponse = null; private HttpEntity httpEntity = null; @ Override protected void onCreate (Bundle savedInstanceState. onCreate (savedInstanceSta Te); setContentView (R. layout. activity_main); button = (Button) findViewById (R. id. button); textView = (TextView) findViewById (R. id. textview); button. setOnClickListener (new OnClickListener () {@ Override public void onClick (View arg0) {// TODO Auto-generated method stub // generate a request object HttpGet httpGet = new HttpGet ("http://www.baidu.com "); // generate an Http client object HttpClient httpClient = new DefaultHttpClient (); // use the Http client The client sends the request object InputStream inputStream = null; try {httpResponse=httpClient.exe cute (httpGet); // read the returned data after receiving the response from the server. httpEntity = httpResponse. getEntity (); inputStream = httpEntity. getContent (); // stream File Read BufferedReader reader = new BufferedReader (new InputStreamReader (inputStream); String resultString = ""; String lineString = ""; while (lineString = reader. readLine ())! = Null) {resultString = resultString + lineString;} textView. setText (resultString);} catch (ClientProtocolException e) {// TODO Auto-generated catch block e. printStackTrace ();} catch (IOException e) {// TODO Auto-generated catch block e. printStackTrace ();} finally {try {inputStream. close () ;}catch (Exception e2) {// TODO: handle exception e2.printStackTrace () ;}}}) ;}@ Override public boolean onCreateOptionsMenu (Menu menu Menu) {// Inflate the menu; this adds items to the action bar if it is present. getMenuInflater (). inflate (R. menu. activity_main, menu); return true ;}</span> Note: Due to network connection, you must declare the network permission in AndroidManifest: [html] <uses-permission android: name = "android. permission. INTERNET "/>