Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When I send SMS, sometimes result code = 0. What does that code mean?

Tags:

android

sms

smsManager.sendMultipartTextMessage(
                mDests[i], mServiceCenter, messages,
                sentIntents, deliveryIntents);

In my SmsReceiver (sentIntents) sometimes I receive getResultCode() = 0.

According to the documentation: http://developer.android.com/reference/android/telephony/SmsManager.html

It means STATUS_ON_ICC_FREE. But I can't understand what it is. When it is returned - SMS are not sent.

What does this mean and how to fix it? What is the reason for STATUS_ON_ICC_FREE?

like image 612
Tim Avatar asked Dec 05 '11 08:12

Tim


People also ask

What is SMS error code?

SMS error code is a number that is sent out whenever there is a problem with the process of sending messages. These sms error codes are like indicating an outcome of what went wrong in the process of sending messages. There are different codes that senders receive when a message fails to be delivered.

Why do my text messages say failed to send?

Some common reasons why SMS messages may be failing to send: The destination handset is unreachable. The destination phone number does not support Text. The SMS message exceeds the 160 character limit.


2 Answers

You're just comparing result code to the wrong constant. SmsManager.sendMultipartTextMessage Javadoc clearly states about the possible values returned by the getResultCode() in the sentIntents broadcast:

The result code will be Activity.RESULT_OK for success, or one of these errors:
RESULT_ERROR_GENERIC_FAILURE
RESULT_ERROR_RADIO_OFF
RESULT_ERROR_NULL_PDU

In my opinion STATUS_ON_ICC_xxx constants were added to the public API by mistake since they are used only by hidden methods of the SmsManager class: copyMessageToIcc, deleteMessageFromIcc etc.

UPDATE

However this doesn't explain why do you receive 0 from getResultCode(). As neither of these constant is equal to zero (Activity.RESULT_CANCEL = 0 but there is no mention of it in the SmsManager javadoc). Quick search through Android Sources also doesn't give any clue were 0 could come from.

One possibility could be that some other application catch the sentIntent broadcast and call setResultCode explicitly. However I was sure up to now that it's impossible in Android to prevent the SMS from being sent at the application level.

like image 60
Idolon Avatar answered Oct 06 '22 01:10

Idolon


The javadoc says Free space (TS 51.011 10.5.3 / 3GPP2 C.S0023 3.4.27).. The 3GPP2 specifications say 3GPP2 C.S0023 3.4.27 status

I don't know anything about SMS, but from what I understand, this "free space" is opposed to the "used space" (xx1 that actually defines statuses such as 001 received & read ; 011 receveid & to be read ; etc.)

I would says this status does not mean anything...

In the Android code, I have found only one reference to STATUS_ON_ICC_FREE: deleteMessageFromIcc() updates the message with this status when the message has successfully been deleted from the SIM card (aka ICC)

like image 21
rds Avatar answered Oct 06 '22 00:10

rds