How can I check whether the Sim Card is available in an android device?
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.
TelephonyManager telMgr = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
int simState = telMgr.getSimState();
switch (simState) {
case TelephonyManager.SIM_STATE_ABSENT:
// do something
break;
case TelephonyManager.SIM_STATE_NETWORK_LOCKED:
// do something
break;
case TelephonyManager.SIM_STATE_PIN_REQUIRED:
// do something
break;
case TelephonyManager.SIM_STATE_PUK_REQUIRED:
// do something
break;
case TelephonyManager.SIM_STATE_READY:
// do something
break;
case TelephonyManager.SIM_STATE_UNKNOWN:
// do something
break;
}
EDIT:
Starting at API 26 (Android O Preview) you can query the SimState for individual sim slots by using getSimState(int slotIndex)
ie:
int simStateMain = telMgr.getSimState(0);
int simStateSecond = telMgr.getSimState(1);
official documentation
If you're developing with and older api, you can use TelephonyManager's
String getDeviceId (int slotIndex)
//returns null if device ID is not available. ie. query slotIndex 1 in a single sim device
int devIdSecond = telMgr.getDeviceId(1);
//if(devIdSecond == null)
// no second sim slot available
which was added in API 23 - docs here
How to check the numbers of SIM in android device
You can use TelephonyInfo
to get details of the dual sim phone.
for better explanation, have a look at this post.
Android : Check whether the phone is dual SIM
How to check if the Android Tablet has simcard feature programatically?
You have to play around with TelephoneyManager to test if it has simcard slot or not .
to be exect try below code. more details from here
public static boolean isSimSupport(Context context)
{
TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); //gets the current TelephonyManager
return !(tm.getSimState() == TelephonyManager.SIM_STATE_ABSENT);
}
Related Topics
How to Change Bitmap Image Color in Android
Disable Sound from Notificationchannel
Passing Touch Events to the Parent View
How to Resolve Java.Util.Zip.Zipexception
Implementing Text Watcher for Edittext
Sign APK Without Putting Keystore Info in Build.Gradle
How to Add Multiple Widgets in the Same App
How to Automatically Restart a Service Even If User Force Close It
Android Videoview Black Screen
What Method Should I Use Now Since Firebaseinstanceid.Getinstance().Gettoken() Is Deprecated
Getting a Photo from a Contact
Getintent() Extras Always Null
Pass Arraylist<? Implements Parcelable> to Activity
How to Change Action Bar Title Color in Code
Adb Server Is Out of Date. Killing
How to Use and Style New Alertdialog from Appcompat 22.1 and Above
Upload a File Through an Http Form, via Multipartentitybuilder, with a Progress Bar
Webview Showing Err_Cleartext_Not_Permitted Although Site Is Https