Wifi ネットワークに接続する Android アプリケーションを作成したいと考えています。ネットワーク SSID = "ABC" とします。Wifi ABC に接続されていると仮定します。ABC に接続した後、同じ wifi ABC ネットワークに接続されているすべての Android デバイスの IP をアプリケーションに表示させたいと思います。どうすればそれを達成できますか? ありがとう
4784 次
2 に答える
4
次のファイルを確認してください: 携帯電話で /proc/net/arp。
同じネットワークに接続されている他のすべてのデバイスの IP アドレスと MAC アドレスが含まれています。ただし、Android フォンであるかどうかを区別することはできません。
于 2011-06-08T19:24:27.797 に答える
1
tcpdump を使用してネットワーク カードを無差別モードにし、パケットをキャプチャして、ネットワーク上の他のクライアントを特定します。
Android で tcpdump を使用する方法: http://source.android.com/porting/tcpdump.html
次のように、コード内でコマンドを実行できます。
try {
// Executes the command.
Process process = Runtime.getRuntime().exec("/system/bin/ls /sdcard");
// Reads stdout.
// NOTE: You can write to stdin of the command using
// process.getOutputStream().
BufferedReader reader = new BufferedReader(
new InputStreamReader(process.getInputStream()));
int read;
char[] buffer = new char[4096];
StringBuffer output = new StringBuffer();
while ((read = reader.read(buffer)) > 0) {
output.append(buffer, 0, read);
}
reader.close();
// Waits for the command to finish.
process.waitFor();
return output.toString();
} catch (IOException e) {
throw new RuntimeException(e);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
于 2011-03-09T04:08:33.877 に答える