달력

4

« 2024/4 »

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
2012. 8. 29. 00:45

안드로이드 - ip 가져오기 안드로이드 이야기2012. 8. 29. 00:45

728x90
반응형

안드로이드 - 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) {


}
}



});
}
}



728x90
반응형
:
Posted by mapagilove