336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.
package com.tistory.tansanc.Test130805; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.net.Socket; import java.net.UnknownHostException; import android.app.Activity; import android.os.Bundle; import android.os.Handler; import android.os.Message; import android.view.View; import android.widget.EditText; import android.widget.TextView; public class MainActivity extends Activity { String msg; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } public void mOnClick(View v) { EditText editText1 = (EditText) findViewById(R.id.editText1); msg = editText1.getText().toString(); MessageSendThread mst = new MessageSendThread(); mst.start(); } class MessageSendThread extends Thread { public void run() { Socket socket = null; PrintWriter out = null; BufferedReader in = null; try { socket = new Socket("115.20.247.141", 2013); out = new PrintWriter(socket.getOutputStream(), true); in = new BufferedReader(new InputStreamReader( socket.getInputStream())); out.println(msg); String receiveString = in.readLine(); Message message = new Message(); message.obj = receiveString; mHandler.sendMessage(message); out.close(); in.close(); socket.close(); } catch (UnknownHostException e) { } catch (IOException e) { } } } Handler mHandler = new Handler() { public void handleMessage(android.os.Message msg) { String receiveString = (String)msg.obj; TextView textView1 = (TextView)findViewById(R.id.textView1) ; textView1.setText(textView1.getText() + "\n" + receiveString); } }; }
'Programming > Android' 카테고리의 다른 글
Android 채팅 서버 소스 01 (0) | 2013.08.20 |
---|---|
Android 채팅 소스 03 (0) | 2013.08.20 |
Android 채팅 소스 01 (0) | 2013.08.20 |
Android Download html (0) | 2013.08.20 |
Andoid 매트로돔 (0) | 2013.08.19 |