正在进行网络扫描项目。有一个android应用程序,它将首先发现连接到当前网络的设备,然后扫描整个网络。
这是我的代码 java file
:
final ListView lv = (ListView) findViewById(R.id.lv);
//final Button btn = (Button) findViewById(R.id.btn);
try {
ArrayList<String> commandLine = new ArrayList<String>();
String cmd;
cmd= ARP_GET_IP_HW;
Process process = Runtime.getRuntime().exec("arp -a");
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream()));
//$NON-NLS-1$
final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>
(this, android.R.layout.simple_list_item_1, commandLine);
// DataBind ListView with items from ArrayAdapter
lv.setAdapter(arrayAdapter);
} catch (IOException e) {
e.printStackTrace();
}
}
在发现设备(路由器的ARP表)中,发生了错误:
java.io.ioexception: cannot run program "arp": error=13, permission denied