title: How to identify phone number in android device and use it as a login credential?
body: <p>I'm using telephony manager to identify the phone number that has been inputted in the edit text. How to identify if the phone number inputted is the number that is currently being used in the android device?</p>
  
  <pre><code>    public void initlogin(String phonenumber) {
          TelephonyManager tMgr = (TelephonyManager) this.getSystemService(Context.TELEPHONY_SERVICE);
          if (ActivityCompat.checkSelfPermission(this, Manifest.permission.READ_SMS) != PackageManager.PERMISSION_GRANTED &amp;&amp; ActivityCompat.checkSelfPermission(this, Manifest.permission.READ_PHONE_NUMBERS) != PackageManager.PERMISSION_GRANTED &amp;&amp; ActivityCompat.checkSelfPermission(this, Manifest.permission.READ_PHONE_STATE) != PackageManager.PERMISSION_GRANTED) {
              // TODO: Consider calling
              //    ActivityCompat#requestPermissions
              // here to request the missing permissions, and then overriding
              //   public void onRequestPermissionsResult(int requestCode, String[] permissions,
              //                                          int[] grantResults)
              // to handle the case where the user grants the permission. See the documentation
              // for ActivityCompat#requestPermissions for more details.
              return;
          }
          String mPhoneNumber = tMgr.getLine1Number();
  
          //Toast.makeText(this, "PHONE NUMEBR "+mPhoneNumber, Toast.LENGTH_SHORT).show();
          if(mPhoneNumber.equals(phonenumber))
          {
              logUser(phonenumber);
              Intent intent=new Intent(Login.this,ListActivity.class);
              startActivity(intent);
              finishAffinity();
          }
          else
          {
              etphonenumber.setError("Enter Your Phone Number First");
              etphonenumber.requestFocus();
          }
      }
  </code></pre>
  
  <p>The phone number inputted should be the number that is currently being used in the android device to login the system.</p>