[Android] phone data to a computer (WiFi)
How to transfer data from mobile phone to a computer via WIFI?
We can use the ServerSocket (Server side) and socket (Client side) to implement as an example,
Selected a photograph sent from the phone to the computer,
Here it must be noted, Server and client needs in the same URL.
Computer side (Server):
First customize a port (this is set to 1111), then build a ServcerSocket,
Then call accept () method, this method would have been to wait until the client side even come in,
The program will execute the next line.
Side of the build method, I use eclipse, direct NEW-> Java project, after the program comes in,
Press RUN (Ctrl + F11) to perform, and then wait for the Android side even come.
Android terminal (Client):
Here I designed, the program started, we chose a photograph sent to the computer side,
Is divided into two stages:
When the first phase, new one socket, and then into the Server-side IP address and Port number,
The second stage, after the first picture is read, in the presence of buffer,
Then use outputstream output to the Server side.
Finally, because we used network transmission, So remember add INTERNET permission to xml.
File listTips: You can preview the content of files by clicking file names^_^
|MainActivity.java||1.74 kB||01-10-13 14:18|
|AndroidManifest.xml||964.00 B||01-10-13 14:18|
|DesktopServerTCP.java||1.43 kB||01-10-13 14:17|
(Add your comment, get 0.1 Point)
- Page 1
- Total 1