Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to get android device macAddress, IMEI no and uniqueId

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 318
    Comment on it

    To grab MAC address first we have to enable device WIFI, after enabling it we can get the MAC address.

    1. public static String macAddress(final Context context){
    2. WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
    3.  
    4. String address;
    5. if(wifiManager.isWifiEnabled()) {
    6. // WIFI ALREADY ENABLED. GRAB THE MAC ADDRESS HERE
    7. WifiInfo info = wifiManager.getConnectionInfo();
    8. address = info.getMacAddress();
    9. } else {
    10. // ENABLE THE WIFI FIRST
    11. wifiManager.setWifiEnabled(true);
    12.  
    13. // WIFI IS NOW ENABLED. GRAB THE MAC ADDRESS HERE
    14. WifiInfo info = wifiManager.getConnectionInfo();
    15. address = info.getMacAddress();
    16. }
    17. return address;
    18. }

    To know your device IMEI number, first generating device id from TelephonyManager class

    1. public static String getIMEI(final Context context) {
    2.  
    3. TelephonyManager tm = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
    4. String imei_number = tm.getDeviceId();
    5. return imei_number;
    6. }
    7.  
    8. //add permission in your manifest file
    9.     <uses-permission android:name="android.permission.READ_PHONE_STATE"/>

    Android Unique ID

    1. public static String getuniqueId(final Context context) {
    2.     String androidId;
    3.     androidId = System.getString(this.getContentResolver(),Settings.Secure.ANDROID_ID);
    4.     return androidId;
    5. }

     

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Reset Password
Fill out the form below and reset your password: