1. Mobile Phone Assistant
1.1 USB Link
Can read the phone's PID and VID, determine the only device, you can install the corresponding driver for the phone, etc.
Socket on fixed port communication
1.2 WIFI Link
PC on the computer in the entire network segment to send UDP packets, mobile phone connected after WiFi can listen to this port, received packets, trying to connect with the pc machine to establish a connection
1.3 Bluetooth
pairing with Bluetoothsocket
2. Use
2.1 data volume, high real-time transmission requirements
Chat Tools, Stock trading
Socket long connection, heartbeat packet, send heartbeat packet to server at every second
2.2 small amount of data
Message Push, precision marketing
send UDP packets every ten minutes , and the packet needs to contain authentication information (app + user ID)
ImportJava.util.Timer;ImportJava.util.TimerTask; Public classTimertest {/** * @paramargs*/ Public Static voidMain (string[] args) {Timer timer=NewTimer (); Timer.schedule (NewTimerTask () {@Override Public voidrun () {System.out.println ("1"); } }, 1000,1000);//executes after 1 seconds and executes once per second }}
[Android] socket on the phone app