title: How to get the device email in Android?
body: <p>I am using Android 6.0 and I am trying to get the device's email(s) which are logged in to that particular device.</p>
  
  <p>I have already followed many answer in Stack Overflow like:</p>
  
  <p><a href="https://stackoverflow.com/questions/2112965/how-to-get-the-android-devices-primary-e-mail-address?noredirect=1&amp;lq=1">How to get the Android device&#39;s primary e-mail address</a></p>
  
  <p><a href="https://stackoverflow.com/questions/2556495/how-can-you-get-an-android-users-email-address">How can you get an Android user&#39;s email address?</a></p>
  
  <p>I tried to get the email array by doing this:</p>
  
  <pre><code>Pattern emailPattern = Patterns.EMAIL_ADDRESS; // API level 8+
          Account[] accounts = AccountManager.get(this).getAccounts();
          Log.i("email","email : "+accounts.length);
  </code></pre>
  
  <p>But I have never been lucky to get any email in that array. And the <code>Log</code> I have mentioned always print <code>0</code> as the size.</p>
  
  <p>Also I have added the following permission in AndroidMainfest.xml:</p>
  
  <pre><code> &lt;uses-permission android:name="android.permission.GET_ACCOUNTS" /&gt;
  </code></pre>
  
  <p>What is it that I am doing wrong?</p>