When I send an SMS using SmsManager, the result intent broadcasted holds a value of 5
Activity.RESULT_OK
SmsManager.RESULT_ERROR_GENERIC_FAILURE
SmsManager.RESULT_ERROR_NO_SERVICE
SmsManager.RESULT_ERROR_NULL_PDU
SmsManager.RESULT_ERROR_RADIO_OFF
What’s meant by every one of them? and please mention a test case that could generate each one.
I know that RESULT_OK denotes a successfully sent SMS. GENERIC_FAILURE occurs for general erros (e.g. I’ve no credit).
But I’ve activated Airplane mode and tried to send an SMS. I’ve thought it would trigger NO_SERVICE error, but a RADIO_OFF was triggered instead. Also the official documentation is not demonstrating them very well.
Here’s my comments on the documentation of SmsManager:
RESULT_ERROR_GENERIC_FAILURE: Generic failure causeSomething went wrong and there’s no way to tell what, why or how.
RESULT_ERROR_NO_SERVICE: Failed because service is currently unavailableYour device simply has no cell reception. You’re probably in the middle of nowhere, somewhere inside, underground, or up in space. Certainly away from any cell phone tower.
RESULT_ERROR_NULL_PDU: Failed because no pdu providedSomething went wrong in the SMS stack, while doing something with a protocol description unit (PDU) (most likely putting it together for transmission).
RESULT_ERROR_RADIO_OFF: Failed because radio was explicitly turned offYou switched your device into airplane mode, which tells your device exactly “turn all radios off” (cell, wifi, Bluetooth, NFC, …).
In the end, most apps need not care why sending an SMS failed (except ask the user if airplane mode is on in case of
RESULT_ERROR_RADIO_OFF), because there’s nothing the app itself can do to remedy it.