Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Send string from Android phone to PC [closed]

How can I can send a string (ex: "hi") to my PC from my Android phone?

like image 370
FlashCreated Avatar asked Dec 28 '10 14:12

FlashCreated


2 Answers

Before doing this in Android, I recommend you read the basics of Java networking:

  • http://download.oracle.com/javase/tutorial/networking/index.html
  • http://www.tutorialized.com/tutorials/Java/Networking/1

Try to get access to a good book. Once you know how to do it in Java, implement a test client in Android & a test server in your PC.

like image 66
Sebastian Roth Avatar answered Oct 01 '22 17:10

Sebastian Roth


I'm actually implementing a socket solution between Android and PC right now! Once you understand the basics behind sockets (by reading the links that Sebastian suggested), you can use the following links as code guides to make your instruments talk:

  • http://thinkandroid.wordpress.com/2010/03/27/incorporating-socket-programming-into-your-applications/

I'm using the client code from the Android socket example link above, and the server example from the Unix socket example on Beej's website (I've been informed that I'm a new user to stackoverflow, so I'm going to link that as a comment to this answer). The Unix socket server is set up to receive a connection and a packet from the client, then send an answer back and close the socket. I modified this so that the server is just a loop that continuously asks for input from the user at the console. It's not a pretty solution (i.e. no user interface on the PC side), but it will at least give you the basics. You can make it pretty later.

like image 25
moscro Avatar answered Oct 01 '22 17:10

moscro