title: How to get device's IMEI/ESN number with code programming But in android > 6
body: <blockquote>
    <p>My Android version is <strong>Marshmallow 6.0</strong></p>
  </blockquote>
  
  <p>How to Find / Get imei number in android > 6 programmatically.</p>
  
  <p>Note : I added READ_PHONE_STATE permission inside AndroidManifest.xml file.</p>
  
  <pre><code>&lt;uses-permission android:name="android.permission.READ_PHONE_STATE"&gt;&lt;/uses-permission&gt;
  </code></pre>
  
  <p>And inside MainActivity</p>
  
  <pre><code>TelephonyManager manager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
  String deviceid = manager.getDeviceId();
  
  //Device Id is IMEI number
  
  Log.d("msg", "Device id " + deviceid);
  </code></pre>