Last active
August 29, 2015 14:23
-
-
Save pressure679/92caf928638bc9684564 to your computer and use it in GitHub Desktop.
Eclipse java project for Android 22
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.sampleprj; | |
import android.app.Activity; | |
import android.os.Bundle; | |
import android.widget.TextView; | |
// import android.view.Menu; | |
//import android.view.MenuItem; | |
//import android.app.Activity; | |
//import android.os.Bundle; | |
//import android.R; | |
//import java.util.Date; | |
import java.net.InetAddress; | |
import java.net.NetworkInterface; | |
import java.util.Enumeration; | |
import java.net.SocketException; | |
public class MainActivity extends Activity { | |
public static Enumeration<NetworkInterface> e; | |
public static NetworkInterface n; | |
public static Enumeration<InetAddress> ee; | |
public static byte[] mymac = new byte[5]; | |
public static InetAddress inet; | |
public static String[] ifaceinets = new String[10]; | |
public static int counter = -1; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
try { | |
e = NetworkInterface.getNetworkInterfaces(); | |
} catch (SocketException se) { | |
se.printStackTrace(); | |
} | |
while (e.hasMoreElements()) { | |
n = (NetworkInterface)e.nextElement(); | |
// if (args[0].equals(n.getDisplayName())) { | |
ee = n.getInetAddresses(); | |
try { | |
mymac = n.getHardwareAddress(); | |
} catch (SocketException se) { | |
se.printStackTrace(); | |
} | |
while (ee.hasMoreElements()) { | |
inet = (InetAddress)ee.nextElement(); | |
counter++; | |
ifaceinets[counter] = inet.toString(); | |
// System.out.println(n.getDisplayName() + " " + inet); | |
} | |
} | |
super.onCreate(savedInstanceState); | |
TextView text = new TextView(this); | |
text.setText(ifaceinets.toString()); | |
setContentView(text); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment