SmsManager的结果错误是什么意思? [英] What's meant by result errors of SmsManager?

查看:64
本文介绍了SmsManager的结果错误是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用 SmsManager 发送短信时,广播的结果意图的值为5

  Activity.RESULT_OKSmsManager.RESULT_ERROR_GENERIC_FAILURESmsManager.RESULT_ERROR_NO_SERVICESmsManager.RESULT_ERROR_NULL_PDUSmsManager.RESULT_ERROR_RADIO_OFF 

每个人是什么意思?并且请提及一个可以生成每个测试用例的测试用例.我知道RESULT_OK表示已成功发送SMS.GENERIC_FAILURE发生于一般错误(例如,我没有信用).

但是我已激活飞行模式并尝试发送短信.我以为它将触发NO_SERVICE错误,但是却触发了RADIO_OFF.另外,官方文档并未很好地说明它们.

解决方案

这是我对 SmsManager的文档:

  • RESULT_ERROR_GENERIC_FAILURE :一般性故障原因

    出了点问题,无法分辨出什么,原因或方式.

  • RESULT_ERROR_NO_SERVICE :失败,因为服务当前不可用

    您的设备根本无法接收信号.您可能处在茫茫荒野中,在地下,地下或太空中.当然可以远离任何手机塔了.

  • RESULT_ERROR_NULL_PDU :失败,因为未提供pdu

    使用协议描述单元(PDU)进行操作时,SMS堆栈中出现了问题(最有可能将其放在一起进行传输).

  • RESULT_ERROR_RADIO_OFF :失败,因为无线电已明确关闭

    您已将设备切换为飞行模式,这会告诉您设备完全关闭所有无线电"(手机,wifi,蓝牙,NFC等).

最后,大多数应用都不必担心为什么发送短信失败(除非询问用户是否在 RESULT_ERROR_RADIO_OFF 情况下启用飞行模式),因为没有任何内容该应用程序本身可以对此进行补救.

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.

解决方案

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.

这篇关于SmsManager的结果错误是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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