本文介绍了通过code安卓魂在Android模拟器电脑的IP地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在Android模拟器通过code我的电脑的IP地址....或者告诉我才达到连接的局域网内所有设备的IP地址来标识每一个唯一...... 。请帮我理清这个问题。
I want to get the ip address of my pc in android emulator through code....or tell me to achive ip address of all devices connected in a lan to identify each one uniquely .......please help me to sort out this problem
在此先感谢
推荐答案
以上功能仅通过检查ARP高速缓存,其中IP地址将取决于如何每一个连接到设备添加一个个都是可能的。使用低于code和检查。只要把按钮与正确的名称,并调用该方法点击
The above functions are possible only by checking the arp cache where the IP address will be added one by one depending on how each one connect to the device. USe the below code and check. Just put button with proper name and call this method on click
public void getClientList() {
int macCount = 0;
BufferedReader br = null;
try {
br = new BufferedReader(new FileReader("/proc/net/arp"));
String line;
while ((line = br.readLine()) != null) {
String[] splitted = line.split(" +");
if (splitted != null && splitted.length >= 4) {
// Basic sanity check
String mac = splitted[3];
if (mac.matches("..:..:..:..:..:..")) {
macCount++;
ClientList.add("Client(" + macCount + ")");
IpAddr.add(splitted[0]);
HWAddr.add(splitted[3]);
Device.add(splitted[5]);
Toast.makeText(
getApplicationContext(),
"Mac_Count " + macCount + " MAC_ADDRESS "
+ mac, Toast.LENGTH_SHORT).show();
for (int i = 0; i < splitted.length; i++)
System.out.println("Addressssssss "
+ splitted[i]);
}
}
}
// ClientList.remove(0);
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
br.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
这篇关于通过code安卓魂在Android模拟器电脑的IP地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!