안드로이드 - ip 가져오기 안드로이드 이야기2012. 8. 29. 00:45
안드로이드 - ip 가져오기
원본 출처: http://handfeel.blogspot.kr/2008/05/ip.html
package com.google.android.ip;
import java.net.InetAddress;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
public class Ip extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.main);
Button cmd_ip = (Button)this.findViewById(R.id.widget23);
final EditText txt_box =(EditText)this.findViewById(R.id.widget24 );
cmd_ip.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
InetAddress Local_ip = null;
try {
InetAddress myIp = null;
myIp = InetAddress.getByName("LocalHost");
//myIp = InetAddress.getByName("www.naver.com");
txt_box.setText(myIp.getHostAddress());
} catch (Exception e) {
}
}
});
}
}
'안드로이드 이야기' 카테고리의 다른 글
안드로이드 - 3G / Wifi 상황에서 IP 가져오기 (0) | 2012.08.29 |
---|---|
안드로이드 - IP 주소 가져오기 (0) | 2012.08.29 |
안드로이드 - 이미지 파일 서버로 업로드하기 (0) | 2012.08.28 |
안드로이드 - 센서 사용 모음 예제 (0) | 2012.08.27 |
안드로이드 - Widget 만들기 (소스 첨부) (0) | 2012.08.24 |