0

hi i was trying to connect My Android app to send data to my PC. i can get the data from PC to my android but i cant send data to my pc with android it is my code :

try 
{                   
    clientSocket = new Socket("192.168.1.90",8080);
    OutputStream out = clientSocket.getOutputStream();
    PrintWriter output = new PrintWriter(out);
    output.println("Hello Android!");
    BufferedReader input = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
    String st = input.readLine();
    clientSocket.close();
    store.add("send it");                   
} 
catch (UnknownHostException e) 
{
    // TODO Auto-generated catch block
    e.printStackTrace();
    store.add(e.toString());
    //error_view.setText(e.toString());
} 
catch (IOException e) 
{
    // TODO Auto-generated catch block
    e.printStackTrace();
    store.add(e.toString());
    //error_view.setText(e.toString());
}
Uriil
  • 11,948
  • 11
  • 47
  • 68
Dana Sorani
  • 77
  • 1
  • 11

1 Answers1

0

It should be like:

  clientSocket = new Socket("192.168.1.90", 8888);
  DataOutputStream dataOutputStream = new DataOutputStream(clientSocket.getOutputStream());
  dataInputStream dataInputStream = new DataInputStream(clientSocket.getInputStream());
  dataOutputStream.writeUTF(textOut.getText().toString());

For more view:

Community
  • 1
  • 1
ridoy
  • 6,274
  • 2
  • 29
  • 60