When I send SMS, sometimes I get the code = 0. What does this code mean?

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

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

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

This means STATUS_ON_ICC_FREE . But I do not understand what it is. When it will be returned - SMS will not be sent.

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

+6
source share
3 answers

You are simply comparing the result code with the wrong constant. SmsManager.sendMultipartTextMessage Javadoc clearly states the possible values ​​returned by getResultCode() in the sentIntents translation:

 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, the STATUS_ON_ICC_xxx constants were added to the public API by mistake, because they are used only by hidden methods of the SmsManager class: copyMessageToIcc , deleteMessageFromIcc , etc.

UPDATE

However, this does not explain why you get 0 from getResultCode() . Since none of these constants is equal to zero ( Activity.RESULT_CANCEL = 0 , but this is not mentioned in the SmsManager javadoc). A quick search through Android Sources also does not give any idea that 0 might occur.

One possibility might be that some other application captures the sentIntent translation and calls setResultCode explicitly. However, until now I was sure that in Android it is impossible to prohibit sending SMS at the application level.

+3
source

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

I don’t know anything about SMS, but from what I understand, this “free space” is contrasted with the “used space” ( xx1 , which actually defines such statuses as 001, received and read; 011 receveid and read, etc. )

I would say that this status does not mean anything ...

In the Android code, I found only one link to STATUS_ON_ICC_FREE : deleteMessageFromIcc() updates the message with this status when the message was successfully deleted from the SIM card (otherwise ICC)

+2
source

You write that you use the following to send text:
smsManager.sendTextMessage(destination, null, message, null, null);

Why don't you use the sentIntent parameter, which can tell you if your message was received on the network?

From the documentation:

sentIntent, if not NULL, this PendingIntent is sent when the message is successfully sent or failed. The result code will be Activity.RESULT_OK for success or one of the following errors:

 RESULT_ERROR_GENERIC_FAILURE RESULT_ERROR_RADIO_OFF RESULT_ERROR_NULL_PDU 

sms

0
source

Source: https://habr.com/ru/post/903084/


All Articles