1 package com.example.server;
2
3 import java.io.BufferedReader;
4 import java.io.IOException;
5 import java.io.InputStreamReader;
6 import java.io.PrintWriter;
7 import java.net.Socket;
8 import java.net.UnknownHostException;
9
10 import android.os.Bundle;
11 import android.os.Handler;
12 import android.app.Activity;
13 import android.view.Menu;
14 import android.view.View;
15 import android.view.View.OnClickListener;
16 import android.widget.Button;
17 import android.widget.EditText;
18 import android.widget.TextView;
19
20 public class MainActivity extends Activity {
21
22 private TextView text;
23 private Button button;
24 private EditText ed;
25 private BufferedReader b;
26 private Socket socket;
27 private PrintWriter pw;
28 private String s;
29
30 Handler hand = new Handler() {
31 public void handleMessage(android.os.Message msg) {
32 // 获取服务器发送的东西
33 String ss = (String) msg.obj;
34 System.out.println(ss + "ssd的值");
35 // 把服务器发送的东西显示在textview上
36 text.setText(text.getText().toString() + "\t\n" + ss);
37
38 };
39 };
40
41 @Override
42 protected void onCreate(Bundle savedInstanceState) {
|