
COMO CREAR UN CLIENTE EN ANDROID STUDIO, QUE ME PERMITA ENVIAR UN VALOR INT AL SERVIDOR
Publicado por Cristian Felipe (6 intervenciones) el 19/02/2016 17:51:04
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
public class MainActivity extends Activity {
private Socket socket;
private static final int SERVERPORT = 8080;
private static final String SERVER_IP = "192.168.1.65";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
new Thread(new ClientThread()).start();
}
public void onClick(View view) {
try {
DataOutputStream Out = new DataOutputStream(socket.getOutputStream());
int led=1;
Out.writeInt(led);
Out.close();
socket.close();
} catch (UnknownHostException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}
que me falta para simplemente poder enviar el valor de led=1 al servidor, muchas gracias
Valora esta pregunta


0