title: How to get the mobile number of my device programmatically?
body: <p>I have tried using 2 methods for retrieving my phone number but both of them don't work. I used:</p>
  
  <ol>
  <li>TelephonyManager</li>
  <li>SubscriptionManager</li>
  </ol>
  
  <p>I do get Network name, Country iso, and IMEI but whenever I try to return Number it returns nothing.</p>
  
  <p>I have also added all the required permissions for these! My manifest looks like:</p>
  
  <pre><code>&lt;uses-permission android:name="android.permission.READ_PHONE_STATE" /&gt;
  &lt;uses-permission android:name="android.permission.READ_PHONE_NUMBERS" /&gt;
  &lt;uses-permission android:name="android.permission.GET_ACCOUNTS" /&gt;
  </code></pre>
  
  <p>Code using <strong>TelephonyManager</strong>:</p>
  
  <pre><code>TelephonyManager phoneMgr = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
  phoneMgr.getLine1Number()
  </code></pre>
  
  <p>Code using <strong>SubscriptionManager</strong>:</p>
  
  <pre><code>if (Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.M) {
          List&lt;SubscriptionInfo&gt; subscription = SubscriptionManager.from(getApplicationContext()).getActiveSubscriptionInfoList();
          for (int i = 0; i &lt; subscription.size(); i++) {
              SubscriptionInfo info = subscription.get(i);
              Log.e("TAG", "number " + info.getNumber());
              Log.e("TAG", "network name : " + info.getCarrierName());
              Log.e("TAG", "country iso " + info.getCountryIso());
          }
      }
  </code></pre>
  
  <p><em>In both attempts I get nothing!</em></p>
  
  <p>Is there any other way to get phone number or I'm doing something wrong?</p>