How do I know if the device is a Smathphone or Tablet and / or is it capable of sending SMS?

1

I developed an application that is able to send an SMS with some information at the touch of a button, but one issue that concerns me is the devices that can not send SMS, type tablet's without a SIM card.

Is there any way I can validate this situation? Is there a SIM card present?

    
asked by anonymous 26.02.2017 / 16:43

1 answer

3

Use the class TelephonyManager .

Using getPhoneType () can tell if it's a phone and your type.

TelephonyManager telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
if(telephonyManager.getPhoneType() == TelephonyManager.PHONE_TYPE_NONE){
    //não é telefone
}

If it's a phone, you can know the status of the SIM using the method getSimState () .

TelephonyManager telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
int phoneType = telephonyManager.getPhoneType();
if(phoneType == TelephonyManager.PHONE_TYPE_NONE){
    //não é telefone
}else if(phoneType == TelephonyManager.PHONE_TYPE_GSM){
    if(telephonyManager.getSimState() == TelephonyManager.SIM_STATE_READY){
        //Tem SIM e está pronto a usar
    }
}

See the documentation for the possible values returned by getPhoneType () and getSimState () .

    
26.02.2017 / 17:15