Juned
Juned

Reputation: 6326

how to get international dialing code based on SIM provider?

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.enter image description here

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

Answers (2)

TejaDroid
TejaDroid

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

Faisal Feroz
Faisal Feroz

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

Related Questions