1. Next¶ó´Â ¾×ƼºñƼ·Î intentÇؼ ³Ñ¾î°¡°í ½ÍÀºµ¥
¾×ƼºñƼ ¹Ù±ù¿¡¼ intent¼±¾ð½Ã ¿¡·¯°¡ ³³´Ï´Ù
2. Next ¾×ƼºñƼ¿¡¼µµ ¼ÒÄÏÅë½ÅÀ» À¯ÁöÇÏ°í ½ÍÀºµ¥ ¾î¶»°Ô ÇؾߵǴÂÁö ¸ð¸£°Ú¾î¿ä. µµ¿ÍÁÖ¼¼¿ä..
¾²·¹µåºÎºÐÀ» ¾î¶»°Ô ÂüÁ¶ÇؾߵÉÁö °¨À̾ȿͿä
3. Next ¾×ƼºñƼ¿¡
import org.androidtown.socket.Connect; ÀÌ·¸°Ô Connect Ŭ·¡½º¸¦ ºÒ·¯¿Ô´Âµ¥
Next ¾×ƼºñƼ¿¡¼ ¾î¶»°Ô ½á¾ßµÇ´Â°ÇÁö ¸ð¸£°Ú¾î¿ä¤Ð
package org.androidtown.socket;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.Socket;
import java.net.UnknownHostException;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class AndroidSocketClient extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button btn = (Button)findViewById(R.id.connect);
btn.setOnClickListener(new Button.OnClickListener(){
public void onClick(View v){
Intent intent = new Intent(AndroidSocketClient.this, Next.class);
startService(intent);
// Connect thread = new Connect();
// thread.setDaemon(true);
// thread.start();
}});
}
}
class Connect extends Thread{
public void run(){
// mHandler.sendEmptyMessage(0);
// EditText ip_edit = (EditText)findViewById(R.id.ip);
// String str = ip_edit.getText().toString();
String str = "118.217.210.159";
int port = 5001;
try {
Socket sock = new Socket(str, port);
ObjectOutputStream outstream = new ObjectOutputStream(sock.getOutputStream());
outstream.writeObject("Hello AndroidTown on Android");
outstream.flush();
Intent intent = new Intent(Connect.this, Next.class);
startActivity(intent);
sock.close();
} catch (UnknownHostException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
//Handler mHandler = new Handler(){
//public void handleMessage(Message msg){
//if(msg.what==0){
}
}
* ±ÛÀ» µî·ÏÇϽǶ§ ²À ÇÊ¿äÇÑ °æ¿ì°¡ ¾Æ´Ï¸é °³ÀÎÁ¤º¸¸¦ ³²±âÁö ¸¶¼¼¿ä ^^ (¿¬¶ôó,À̸ÞÀÏÁÖ¼Ò,Áֹεî·Ï¹øÈ£ µî)