Wednesday, 5 June 2013

Android - How to get device Phone Number in Android


How to get device Phone Number in Android


Step 1:  put code in .java file
               TelephonyManager mTelephonyMgr;  
            mTelephonyMgr = (TelephonyManager)        getSystemService(Context.TELEPHONY_SERVICE);   

                String yourNumber = mTelephonyMgr.getLine1Number();
                Toast.makeText(getApplicationContext(), "Your Phone Number is = " + yourNumber , Toast.LENGTH_LONG).show();


Step 2:  For Getting Phone Number Permission is given in AndroidManifest.xml

         <uses-permission android:name="android.permission.READ_PHONE_STATE" />

No comments:

Post a Comment