Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's meant by result errors of SmsManager?

Tags:

android

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.

like image 732
Islam Hassan Avatar asked Oct 20 '12 11:10

Islam Hassan


People also ask

What is SmsManager in Android?

↳ android.telephony.SmsManager. Manages SMS operations such as sending data, text, and pdu SMS messages. Get this object by calling the static method getDefault() . To create an instance of SmsManager associated with a specific subscription ID, call getSmsManagerForSubscriptionId(int) .

What are the steps involved in sending SMS through Android application discuss?

Before starting your application, Android studio installer will display following window to select an option where you want to run your Android application. Now you can enter a desired mobile number and a text message to be sent on that number. Finally click on Send SMS button to send your SMS.


1 Answers

Here's my comments on the documentation of SmsManager:

  • RESULT_ERROR_GENERIC_FAILURE: Generic failure cause

    Something went wrong and there's no way to tell what, why or how.

  • RESULT_ERROR_NO_SERVICE: Failed because service is currently unavailable

    Your 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 provided

    Something 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 off

    You 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.

like image 77
Philipp Reichart Avatar answered Oct 22 '22 07:10

Philipp Reichart