Está en la página 1de 1

//Mandar un mensaje a la computadora desde Android import java.net.*; import java.io.*; import android.widger.

*; //Tomando en cuenta los componentes del .xml public class MainActivity extends Activity { EditText et; Socket et; Button boton; boolean conexion; Message_data msg; public void onCreate(Bundle savedInstance) { super.onCreate(savedInstance); et = (EditText)findViewById(R.id.et); boton = (Button)findViewById(R.id.boton); try { s = new Socket(IP, PUERTO); if (s.isConnected) conexion = true; } catch (Exception E) { } boton.setOnClickListener(new OnClickListenener()) { publid void onClick() { if(conexion) { ObjectOutpuStream oos = new ObjectOutput Stream(s.getOutputStream); meg = et.getText(); oos.writeObject(msg); s.close(); oos.close(); } } } } }

También podría gustarte