Android手機做熱點時,如何擷取連過來裝置的具體資訊?

來源:互聯網
上載者:User

標籤:android   熱點   擷取資訊   

1、串連過來的裝置的資訊存放在/data/misc/dhcp/dnsmasq.leases中


2、它的格式是:
/系統id,不需取值/client mac地址/client ip地址/ client device name/加權後mac地址,也不需取值

<span style="font-size:14px;">1357041758 88:00:12:34:56:78 192.168.43.133 android-184cc6c105d7a3b 01:88:00:12:34:56:78</span>



2、參考WifiServie.java的getClientIp()方法,可以自訂這個方法取得device name,具體如下:
<span style="font-size:14px;">public String getClientDeviceName(String deviceAddress) {//傳mac地址進來enforceAccessPermission();if (TextUtils.isEmpty(deviceAddress)) {return null;}//讀取對應的檔案資訊for (String s : readClientList("/data/misc/dhcp/dnsmasq.leases")) {if (s.indexOf(deviceAddress) != -1) {String[] fields = s.split(" ");//校正資料是否破損if (fields.length > 4) {//返回第4個欄位return fields[3];}}}return null;}</span>


轉載請註明出處:周木水的CSDN部落格 http://blog.csdn.net/zhoumushui

我的GitHub:周木水的GitHub https://github.com/zhoumushui



Android手機做熱點時,如何擷取連過來裝置的具體資訊?

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.