偷偷摘套内射激情视频,久久精品99国产国产精,中文字幕无线乱码人妻,中文在线中文a,性爽19p

實(shí)現(xiàn)Android手機(jī)通過(guò)WIFI和PC連接

移動(dòng)開(kāi)發(fā) Android
大家如果手邊沒(méi)有路由器,只有無(wú)線網(wǎng)卡,一樣可以使用手機(jī)自帶的Wifi上網(wǎng),前提電腦必須具備有線網(wǎng)絡(luò),并且無(wú)線網(wǎng)卡驅(qū)動(dòng)已經(jīng)正常安裝!Let's go!其它Andro手機(jī)應(yīng)該也可以使用。

最近一段事件一直在研究如何用wifi和PC連接,但是在網(wǎng)上找了很久,也看過(guò)很多例子。都沒(méi)有成功。無(wú)奈只好自己研究。***自己寫了一個(gè)小Demo。分享一下。[[69567]]

1.在程序中通過(guò)

  1. Runtime.getRuntime().exec("su"); 

獲得手機(jī)root權(quán)限(手機(jī)必須是root之后的)。

2.重新啟動(dòng)adbd

  1. exec("stop adbd"); 
  2. exec("start adbd"); 

3.與PC建立連接(我是通過(guò)bat文件進(jìn)程處理的)

  1. /** 
  2.          * 手機(jī)連接wifi. 
  3.          * 
  4.          * @param host 手機(jī)ip:端口號(hào)。例如:192.168.10.124:8888 
  5.          */ 
  6.         public int connectWifi(String host) { 
  7.             String cmd = ParseProperties.getProperties("dir") 
  8.                     + "bin/ConnectWifi.bat " + host; 
  9.             BufferedReader reader = null
  10.             int retcode = 0
  11.             try { 
  12.                 Process process = Runtime.getRuntime().exec(cmd); 
  13.       
  14.                 reader = new BufferedReader(new InputStreamReader( 
  15.                         process.getInputStream())); 
  16.                 @SuppressWarnings("unused") 
  17.                 String line = null
  18.                 String returnLine = null
  19.                 System.out.println("*****************************"); 
  20.                 while ((line = reader.readLine()) != null) { 
  21.                     if (line != null) 
  22.                         returnLine = line
  23.                     System.out.println(line); 
  24.                 } 
  25.                 if (returnLine.trim().startsWith("connected to")) { 
  26.                     retcode = SUCCESS
  27.                 } else if (returnLine.trim().startsWith("already connected to")) { 
  28.                     retcode = SUCCESS
  29.                 } else { 
  30.                     retcode = FAILE
  31.                 } 
  32.                 System.out.println("*****************************"); 
  33.             } catch (IOException e) { 
  34.                 e.printStackTrace(); 
  35.                 retcode = FAILE
  36.             } finally { 
  37.                 if (reader != null) { 
  38.                     try { 
  39.                         reader.close(); 
  40.                     } catch (Exception e) { 
  41.                         e.printStackTrace(); 
  42.                     } 
  43.                 } 
  44.             } 
  45.             if (retcode == 0) { 
  46.                 retcode = FAILE
  47.             } 
  48.             return retcode; 
  49.         } 

bat文件

bat文件中的內(nèi)用很簡(jiǎn)單 adb connect %1

通過(guò)上述方法就能通過(guò)wifi和PC連接在一起了。注意:手機(jī)和PC機(jī)要在同一個(gè)局域網(wǎng)中。

責(zé)任編輯:閆佳明 來(lái)源: oschina
相關(guān)推薦

2020-08-28 10:01:08

AndroidPC手機(jī)屏幕

2018-01-24 16:30:43

Linux命令Wifi

2019-11-08 10:00:09

Windows手機(jī)應(yīng)用程序

2023-06-12 15:35:04

綜合布線光纖以太網(wǎng)

2022-09-11 19:55:46

MAC 地址WiFi 地址

2021-04-30 12:17:18

ChromiumEdge瀏覽器

2009-12-16 10:23:04

家庭無(wú)線路由設(shè)置

2021-11-08 05:33:25

PC安卓手機(jī)投屏

2013-01-24 11:09:57

索尼存儲(chǔ)NFC

2021-09-14 09:50:29

物聯(lián)網(wǎng)超連接IOT

2014-10-29 10:38:36

手機(jī)PC協(xié)議

2011-12-15 09:58:38

Wifi私有云

2011-12-15 13:14:08

免費(fèi)wifi私有云

2012-02-22 11:08:07

UbuntuAndroid

2010-05-18 10:07:23

桌面PC云計(jì)算

2019-12-09 16:52:31

華為鴻蒙

2023-03-29 10:03:36

2020-11-02 11:56:57

鴻蒙 WiFi操作

2009-04-04 08:54:07

2009-04-06 08:20:31

AndroidGoogle移動(dòng)OS
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)