Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

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

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report