当我发短信,有时会导致code = 0,这是什么code是什么意思? [英] When I send SMS, sometimes result code = 0. What does that code mean?
问题描述
smsManager.sendMultipartTextMessage(
mDests[i], mServiceCenter, messages,
sentIntents, deliveryIntents);
在我SmsReceiver(sentIntents)有时我收到的getResult code()= 0
。
In my SmsReceiver (sentIntents) sometimes I receive getResultCode() = 0
.
根据文档: http://developer.android.com/reference /android/telephony/SmsManager.html
这意味着 STATUS_ON_ICC_FREE
。但我不明白它是什么。
当它被返回 - 短信不被发送
It means STATUS_ON_ICC_FREE
. But I can't understand what it is.
When it is returned - SMS are not sent.
这是什么意思,如何解决?什么是 STATUS_ON_ICC_FREE
?
What does this mean and how to fix it? What is the reason for STATUS_ON_ICC_FREE
?
推荐答案
你只是比较结果code到错误不断。 <一href="http://developer.android.com/reference/android/telephony/SmsManager.html#sendMultipartTextMessage%28java.lang.String,%20java.lang.String,%20java.util.ArrayList%3Cjava.lang.String%3E,%20java.util.ArrayList%3Candroid.app.PendingIntent%3E,%20java.util.ArrayList%3Candroid.app.PendingIntent%3E%29"相对=nofollow> SmsManager.sendMultipartTextMessage
Javadoc中明确规定有关由的getResult code可能返回的值()
在 sentIntents
广播:
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
在我看来 STATUS_ON_ICC_xxx
常数被添加到错误的公共API,因为它们只能由SmsManager的类的隐藏方法: copyMessageToIcc
, deleteMessageFromIcc
等。
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.
更新
不过,这并不能解释为什么您会收到 0
从的getResult code()
。由于这些都不恒等于零( Activity.RESULT_CANCEL = 0
但在没有提到它 SmsManager的
的javadoc)。 快速搜索通过Android的来源也没有给出任何线索是 0
可能来自。
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.
一种可能是,其他一些应用程序赶上 sentIntent
广播呼叫的setResult code
明确。不过,我敢肯定到现在为止,这是不可能在Android中,以prevent被发送在应用级的短信。
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.
这篇关于当我发短信,有时会导致code = 0,这是什么code是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!