0
我想從局域網獲得ping
以查看我的LAN上有哪些設備。如何在android studio中ping(在LAN 1到255中)
這是我的代碼:
TextView info = (TextView) findViewById(R.id.info);
String alive = "";
for (int i = 0; i < 256; i++) {
Process p = Runtime.getRuntime().exec("/system/bin/ping -c 1 192.168.1." + i);
info.setText("");
int status = p.waitFor();
if (status == 0) {
alive = alive + " - " + i;
Log.d("Hey", i+"");
}
此代碼工作正常,但這個過程是非常耗時。
ty for answer,你能告訴我簡單的代碼嗎? –