title: How to get phone number or sim card information use android studio?
body: <p>How to get phone number or sim card information use android studio? (simcard 1 or 2)</p>
  
  <p>I have used this code:</p>
  
  <pre><code>TelephonyManager tMgr = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
  phone_number.setText(tMgr.getLine1Number());
  </code></pre>
  
  <p>And I've also added permissions in AndroidManifest:</p>
  
  <pre><code>&lt;uses-permission android:name="android.permission.READ_PHONE_STATE"/&gt;
  </code></pre>
  
  <p>But all the gadgets that I apply fail to get phone number or always generate a null value.</p>
  
  <p>And this is the build.gradle I use:</p>
  
  <pre><code>dependencies {
     implementation fileTree(dir: 'libs', include: ['*.jar'])
     //noinspection GradleCompatible
     implementation 'com.android.support:appcompat-v7:27.1.1'
     implementation 'com.android.support.constraint:constraint-layout:1.1.0'
     //noinspection GradleCompatible
     implementation 'com.google.android.gms:play-services-maps:15.0.1'
     implementation 'com.google.android.gms:play-services-location:15.0.1'
     testImplementation 'junit:junit:4.12'
     androidTestImplementation 'com.android.support.test:runner:1.0.2'
     androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
  
     //noinspection UseOfBundledGooglePlayServices
     implementation 'com.google.android.gms:play-services:12.0.1'
     implementation 'com.google.android.gms:play-services-auth:15.0.1'
  }
  </code></pre>