I need help checking whether a device has a sim card programatically. Please provide sample code.
I need help checking whether a device has a sim card programatically. Please provide
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Use TelephonyManager.
http://developer.android.com/reference/android/telephony/TelephonyManager.html
As Falmarri notes, you will want to use getPhoneType FIRST of all, to see if you are even dealing with a GSM phone. If you are, then you can also get the SIM state.
EDIT:
Starting at API 26 (Android O Preview) you can query the SimState for individual sim slots by using
getSimState(int slotIndex)ie:official documentation
If you’re developing with and older api, you can use
TelephonyManager'swhich was added in API 23 – docs here