简体   繁体   中英

Check if a phone can send SMS

I've already read some related question about it but most of them were targeting calls, not SMS. What I've found so far is:

TelephonyManager manager = (TelephonyManager) context
        .getSystemService(Context.TELEPHONY_SERVICE);
if (manager.getPhoneType() == TelephonyManager.PHONE_TYPE_NONE) {
    // I guess here are devices that are unable to send SMS
} else {
    // can send SMS
}

Is this true, devices with TelephonyManager.PHONE_TYPE_NONE are unable to send SMS? I don't really understand the description of TelephonyManager.PHONE_TYPE_NONE, which is "No phone radio."

Thanks!

Yes with TelephonyManager.PHONE_TYPE_NONE you can't send SMS.As radio network is required to send SMS. However you can use some IP based messengers like whats app, ebuddy on them

if you see android.hardware.telephony (which you specify using uses-feature tag in Android manifest file), you will notice send/read/write SMS are mentioned under this feature.

Galaxy TAB example,Can't make calls still phone type comes as PHONE_TYPE_CDMA , so adding additional check for line number will be required for such cases, as shown in above link

Use the following code:

Boolean canSendSMS (Context context)
{
PackageManager pm = context.getPackageManager();
return (pm.hasSystemFeature(PackageManager.FEATURE_TELEPHONY) || pm.hasSystemFeature(PackageManager.FEATURE_TELEPHONY_CDMA))
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM