Get the App
SLTechnology News&Howtos  ›  Development  › 

How to realize the connection of Android mobile phone through WIFI and PC

Shulou Source: shulou.com Published: 2022-06-02 12:43:11 10月26日 Update

This article mainly introduces how to achieve Android mobile phone through WIFI and PC connection, the article is very detailed, has a certain reference value, interested friends must read it!

1. Pass in the program

Runtime.getRuntime () .exec (su)

Get the root permission for the phone (the phone must be after root).

two。 Restart adbd

Exec ("stop adbd"); exec ("start adbd")

3. Establish a connection with PC (I handled it through the bat file process)

/ * Mobile phone connects to wifi. * * @ param host Mobile ip: Port number. For example: 192.168.10.124 ParseProperties.getProperties 8888 * / public int connectWifi (String host) {String cmd = ParseProperties.getProperties ("dir") + "bin/ConnectWifi.bat" + host; BufferedReader reader = null; int retcode = 0; try {Process process = Runtime.getRuntime () .exec (cmd) Reader = new BufferedReader (new InputStreamReader (process.getInputStream (); @ SuppressWarnings ("unused") String line = null; String returnLine = null; System.out.println ("*") While ((line = reader.readLine ())! = null) {if (line! = null) returnLine = line; System.out.println (line);} if (returnLine.trim (). StartsWith ("connected to")) {retcode = SUCCESS } else if (returnLine.trim (). StartsWith ("already connected to")) {retcode = SUCCESS;} else {retcode = FAILE;} System.out.println ("*") } catch (IOException e) {e.printStackTrace (); retcode = FAILE;} finally {if (reader! = null) {try {reader.close () } catch (Exception e) {e.printStackTrace ();} if (retcode = = 0) {retcode = FAILE;} return retcode;}

Bat file

The internal use in the bat file is simple adb connect 1

Through the above method, you can connect with PC through wifi. Note: the mobile phone and PC should be in the same local area network.

The above is all the contents of the article "how to connect Android phones through WIFI and PC". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Tags: Mobile phones documents content articles values interests slogans guys partners local area networks methods more permissions knowledge programs industries information channels processes Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information Huawei Microsoft Redmi Shulou Technology