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
    • 298
    Comment on it

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

    public static String macAddress(final Context context){
            WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
    
            String address;
            if(wifiManager.isWifiEnabled()) {
                // WIFI ALREADY ENABLED. GRAB THE MAC ADDRESS HERE
                WifiInfo info = wifiManager.getConnectionInfo();
                address = info.getMacAddress();
            } else {
                // ENABLE THE WIFI FIRST
                wifiManager.setWifiEnabled(true);
    
                // WIFI IS NOW ENABLED. GRAB THE MAC ADDRESS HERE
                WifiInfo info = wifiManager.getConnectionInfo();
                address = info.getMacAddress();
            }
            return address;
        }

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

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

    Android Unique ID

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

     

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: