Reputation: 6326
i am developing the application in which user mobile no and international country code should be set automatically on the basis of SIM card provider.
i.e if i install this application in first page country code and my phone no should be filled automatically.i want this result as my output.
i have done this using static code but i want to do dynamically.if user uses this application then country code and mobile no should be selected automatically.
i have searched on net but there is not a exact answer of this question.
I have seen the application in which they are doing this thing so how they are doing?
Thanks
Upvotes: 0
Views: 1637
Reputation: 6811
There is also one library which will helpful to you for validate user entered Phone number as
http://code.google.com/p/libphonenumber/
Upvotes: 4
Reputation: 12785
Here is the code snippet that will help you in getting the phone number:
TelephonyManager tMgr = (TelephonyManager)mAppContext.getSystemService(Context.TELEPHONY_SERVICE);
String phoneNumber = tMgr.getLine1Number();
Don't forget to include READ_PHONE_STATE
permission in manifest file.
Upvotes: 0