日本综合一区二区|亚洲中文天堂综合|日韩欧美自拍一区|男女精品天堂一区|欧美自拍第6页亚洲成人精品一区|亚洲黄色天堂一区二区成人|超碰91偷拍第一页|日韩av夜夜嗨中文字幕|久久蜜综合视频官网|精美人妻一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
實現(xiàn)Android手機(jī)通過WIFI和PC連接

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

讓客戶滿意是我們工作的目標(biāo),不斷超越客戶的期望值來自于我們對這個行業(yè)的熱愛。我們立志把好的技術(shù)通過有效、簡單的方式提供給客戶,將通過不懈努力成為客戶在信息化領(lǐng)域值得信任、有價值的長期合作伙伴,公司提供的服務(wù)項目有:域名注冊、雅安服務(wù)器托管、營銷軟件、網(wǎng)站建設(shè)、延慶網(wǎng)站維護(hù)、網(wǎng)站推廣。

1.在程序中通過

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

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

2.重新啟動adbd

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

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

 
 
  1. /** 
  2.          * 手機(jī)連接wifi. 
  3.          * 
  4.          * @param host 手機(jī)ip:端口號。例如: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)用很簡單 adb connect %1

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


網(wǎng)頁題目:實現(xiàn)Android手機(jī)通過WIFI和PC連接
網(wǎng)頁網(wǎng)址:http://www.dlmjj.cn/article/dpchesp.html