在失败的Andr​​oid手机短信的送达通知:假阳性 [英] Android SMS delivery notification on failure: false positive

查看:234
本文介绍了在失败的Andr​​oid手机短信的送达通知:假阳性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序发送从一个设备一个短信到另一台。

My application sends a SMS from one device to another.

的问题是,当接收装置断开时,还能获得一个行通知意图

The problem is that when the receiving device is switched off, I still get an OK notification intent.

这是我所得到的,当短信果然不负众望(1号线),当它不传递,因为第二个设备被关闭:

This is what I get when the SMS is really delivered (the 1st line) and when it is not delivered because the 2nd device is shut down:

delivered: intent=Intent { act=SMS_DELIVERED flg=0x10 (has extras) } extras=Bundle{ pdu => [B@41a7a850; format => 3gpp; }Bundle
delivered: intent=Intent { act=SMS_DELIVERED flg=0x10 (has extras) } extras=Bundle{ pdu => [B@41719ae8; format => 3gpp; }Bundle

有没有便携式(未提供相关)的方式,找出如果SMS已交付?

Is there a portable (not provider-dependent) way to find out if the SMS has been delivered?

推荐答案

函数的 SmsMessage.getStatus()给出了状态code。状态code 0表示成功(当然,仅适用于GSM);非零状态codeS取决于它是否是CDMA或GSM消息

The function SmsMessage.getStatus() gives a status code. The status code 0 means success (well, only for GSM); non-zero status codes depend on whether it is a CDMA or GSM message.

所以有:

int status = -1;
byte[] pdu = intent.getByteArrayExtra("pdu");
if (pdu != null) {
    SmsMessage sms = SmsMessage.createFromPdu(pdu);
    status =  sms.getStatus();
}

余获取日志中,相应地,当接收设备是关闭和

I get in the logs, correspondingly, when the receiving device is off and on:

status = 0x30
status = 0x0

但是,这还不是全部: C.S0015-B,2.0版,4.5.21 的(的链接)(针对CDMA)读取(请注意,Android的移动这些值留下16位,并分割状态字节分为两个做状态= mBearerData.errorClass<< 8,状态| = mBearerData.messageStatus; ):

But that's not all: C.S0015-B, v2.0, 4.5.21 (link) (for CDMA) reads (note that Android shifts these values 16 bits left, and splits the status byte into two doing status = mBearerData.errorClass << 8; status |= mBearerData.messageStatus;):

Status
Code     Message Status 
ERROR_CLASS = ‘00’ (no error) 
‘000000’ Message accepted 
‘000001’ Message deposited to Internet 
‘000010’ Message delivered 
‘000011’ Message cancelled 

ERROR_CLASS = ‘10’ (temporary condition) 
‘000100’ Network congestion 
‘000101’ Network error 
‘011111’ Unknown error 

ERROR_CLASS = ‘11’ (permanent condition) 
‘000100’ Network congestion 
‘000101’ Network error 
‘000110’ Cancel failed 
‘000111’ Blocked destination 
‘001000’ Text too long 
‘001001’ Duplicate message 
‘001010’ Invalid destination 
‘001101’ Message expired 
‘011111’ Unknown error 
All other values reserved. 

TS 23.040,9.2.3.15 TP-状态的(的链接)(用于GSM)内容如下:

and TS 23.040, 9.2.3.15 TP-Status (link) (for GSM) reads:

Short message transaction completed
0000000 Short message received by the SME
0000001 Short message forwarded by the SC to the SME but the SC is
unable to confirm delivery
0000010 Short message replaced by the SC
Reserved values
0000011..0001111 Reserved
0010000..0011111 Values specific to each SC

Temporary error, SC still trying to transfer SM
0100000 Congestion
0100001 SME busy
0100010 No response from SME
0100011 Service rejected
0100100 Quality of service not available
0100101 Error in SME
0100110..0101111 Reserved
0110000..0111111 Values specific to each SC

Permanent error, SC is not making any more transfer attempts
1000000 Remote procedure error
1000001 Incompatible destination
1000010 Connection rejected by SME
1000011 Not obtainable
1000100 Quality of service not available
1000101 No interworking available
1000110 SM Validity Period Expired
1000111 SM Deleted by originating SME
1001000 SM Deleted by SC Administration
1001001 SM does not exist (The SM may have previously existed in the SC but the SC
        no longer has knowledge of it or the SM
        may never have previously existed in the SC)
1001010..1001111 Reserved
1010000..1011111 Values specific to each SC

Temporary error, SC is not making any more transfer attempts
1100000 Congestion
1100001 SME busy
1100010 No response from SME
1100011 Service rejected
1100100 Quality of service not available
1100101 Error in SME
1100110..1101001 Reserved
1101010..1101111 Reserved
1110000..1111111 Values specific to each SC

有不正确的检查只0因为状态code可以恰好是2,而事实上,在CDMA消息传递code是2,而不是0! 最重要的是要知道是否有更多的尝试会进行,也就是审查位5-6或4-5(甚至是消息类位的组合有不同的含义!)的值的0x30 在我的日志上述手段 0110000 具体到服务中心值和为0x0 的意思是短由中小企业哪里SME(短消息实体)是任何SMS的事情,接收到的消息即,在这种情况下,接收装置

It is incorrect to check for just 0 because the status code may happen to be 2, and in fact, the CDMA "message delivered" code is 2 rather than 0 ! What is important is to know whether more attempts will be made, that is, to examine the bits 5-6 or 4-5 (and even the message class bit combinations have different meanings!) The value 0x30 in my log above means 0110000 "value specific to Service Centre" and 0x0 means "Short message received by the SME" where SME (Short Message Entity) is any SMS-capable thing, that is, the receiving device in this case.

现在,你必须 intent.getStringExtra(格式)键,取决于它是否是3GPP3GPP2德$ C C的状态code $。

Now, you have to intent.getStringExtra("format") and depending on whether it is "3gpp" or "3gpp2" decode the status code.

如果任何人都可以写code的的GSM和CDMA网络下进行测试,请在发布测试code!

If anyone can write the code and test it under both GSM and CDMA networks, please post the tested code!

这篇关于在失败的Andr​​oid手机短信的送达通知:假阳性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆