package exercice1.identificateur.ex;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.util.Enumeration;
import android.app.ListActivity;
import android.os.Bundle;
import android.util.Log;
import android.widget.ArrayAdapter;
import android.widget.TextView;
import exercice1.identificateur.R;
public class wifi1 extends ListActivity {
private static final String LOG_TAG = null;
public String getLocalIpAddress() {
try {
for (Enumeration en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements();) {
NetworkInterface intf = en.nextElement();
for (Enumeration enumIpAddr = intf.getInetAddresses(); enumIpAddr.hasMoreElements();) {
InetAddress inetAddress = enumIpAddr.nextElement();
if (!inetAddress.isLoopbackAddress()) {
return inetAddress.getHostAddress().toString();
}
}
}
} catch (SocketException ex) {
Log.e(LOG_TAG, ex.toString());
}
return null;
}
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TextView tv = new TextView(this);
tv.setText(getLocalIpAddress());
setContentView(tv);
}
}
'Programming & Tools > Android' 카테고리의 다른 글
[Android] File Stream Read / Write (0) | 2011.05.17 |
---|---|
[Android] "Failed to install xxxxxxx.apk on device 'M110axxxxx': timeout" (1) | 2011.04.07 |
[Android] Title Bar 없애는 방법 (0) | 2011.04.01 |
[Andorid] JNI 로 작성한 파일 디버깅 (0) | 2011.02.24 |
[Android] JNI 를 사용한 socket 생성 시 error (0) | 2011.02.24 |