I have to make an application which shows the contact no of the SIM card that is being used in the cell. For that I need to use TelephonyManager
class. Can I get details on its usage?
How do I find my SIM card number? Your SIM card number (also called ICCID) is normally printed on your SIM card and/or your SIM card packaging, it is always a good idea to keep your SIM card packaging in case you ever need to check your SIM card number at a later date.
You can use the TelephonyManager
to do this:
TelephonyManager tm = (TelephonyManager)getSystemService(TELEPHONY_SERVICE); String number = tm.getLine1Number();
The documentation for getLine1Number()
says this method will return null
if the number is "unavailable", but it does not say when the number might be unavailable.
You'll need to give your application permission to make this query by adding the following to your Manifest:
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
(You shouldn't use TelephonyManager.getDefault()
to get the TelephonyManager
as that is a private undocumented API call and may change in future.)
Hi Actually this is my same question but I didn't get anything.Now I got mobile number and his email-Id from particular Android real device(Android Mobile).Now a days 90% people using what's App application on Android Mobile.And now I am getting Mobile no and email-ID Through this What's app API.Its very simple to use see this below code.
AccountManager am = AccountManager.get(this); Account[] accounts = am.getAccounts(); for (Account ac : accounts) { acname = ac.name; if (acname.startsWith("91")) { mobile_no = acname; }else if(acname.endsWith("@gmail.com")||acname.endsWith("@yahoo.com")||acname.endsWith("@hotmail.com")){ email = acname; } // Take your time to look at all available accounts Log.i("Accounts : ", "Accounts : " + acname); }
and import this API
import android.accounts.Account; import android.accounts.AccountManager;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With