public
class
activity_4
extends
Activity {
public
void
onCreate(Bundle savedInstanceState) {
super
.onCreate(savedInstanceState);
setContentView(R.layout.activity_4);
ArrayList < String > arrayList =
new
ArrayList < String > ();
arrayList.add(
"전화번호 : "
+ getMyTelephony(
1
));
arrayList.add(
"아이피 주소 : "
+ getMyNetwork(
1
));
arrayList.add(
"맥 주소 : "
+ getMyNetwork(
2
));
arrayList.add(
"SSID,BSSID : "
+ getMyNetwork(
3
));
arrayList.add(
"IMEI : "
+ getMyTelephony(
2
));
ArrayAdapter < String > adapter;
adapter =
new
ArrayAdapter < String > (
this
, android.R.layout.simple_list_item_1, arrayList);
ListView listView = (ListView) findViewById(R.id.list4);
listView.setAdapter(adapter);
}
public
String getMyTelephony(
int
num) {
TelephonyManager tMgr = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
switch
(num) {
case
1
:
{
String mPhoneNumber = tMgr.getLine1Number();
if
(mPhoneNumber ==
""
) {
return
"번호없음"
;
}
return
mPhoneNumber;
}
case
2
:
{
String device_id = tMgr.getDeviceId();
return
device_id;
}
}
return
null
;
};
public
String getMyNetwork(
int
num) {
WifiManager wifiMgr = (WifiManager) getSystemService(WIFI_SERVICE);
WifiInfo wifiInfo = wifiMgr.getConnectionInfo();
switch
(num) {
case
1
:
int
ip = wifiInfo.getIpAddress();
String ipAddress = Formatter.formatIpAddress(ip);
return
ipAddress;
case
2
:
String macAddress = wifiInfo.getMacAddress();
return
macAddress;
case
3
:
String a = wifiInfo.getSSID();
String b = wifiInfo.getBSSID();
return
a + b;
case
4
:
String androidID = android.provider.Settings.Secure.ANDROID_ID;
return
androidID;
}
return
null
;
};