Android SMS 发送结果

Posted

技术标签:

【中文标题】Android SMS 发送结果【英文标题】:Android SMS delivered result 【发布时间】:2011-11-02 17:10:57 【问题描述】:

我正在为安卓开发一个短信应用。我想保存消息状态(例如,发送时)

但接收方在发送 SMS 时总是返回 RESULT_OK。这是我正在使用的代码:

        Main.context.registerReceiver(new BroadcastReceiver() 
        @Override
        public void onReceive(Context arg0, Intent arg1) 
            switch (getResultCode()) 
            case Activity.RESULT_OK:

                Main.log("SMS delivered");
                LogThread logThreadEntregado = new LogThread(main, smsId);
                logThreadEntregado.setEntregado();
                Thread t6 = new Thread(logThreadEntregado);
                // t6.run();
                Main.mHandler.post(t6);
                Main.context.unregisterReceiver(this);
                break;
            case Activity.RESULT_CANCELED:
                Main.log("SMS not delivered");
                LogThread logThreadNoEntregado = new LogThread(main, smsId);
                logThreadNoEntregado.setNoEntregado();
                Thread t7 = new Thread(logThreadNoEntregado);
                Main.mHandler.post(t7);
                Main.context.unregisterReceiver(this);
                // t7.run();
                break;
            
        
    , new IntentFilter(DELIVERED));

我想知道是否有方法(可能使用参数 Context arg0、Intent arg1)来检查消息是否已真正传递。

提前谢谢你

【问题讨论】:

【参考方案1】:

Kannel 将通过您在 SMS 提交中的 dlr-url 参数中指定的 url 向您发送发送报告,例如 example.com/DLR?outgoing_id=123&status=%d。

你用什么语言写的无关紧要。您所需要的只是一个通过 HTTP GET 接受特定参数的 HTTP 页面。 Kannel 会为发送状态、时间等添加参数,您将通过上面的 id 将它们链接到您的 SMS 提交。

This discussion有一个明显的例子。

【讨论】:

以上是关于Android SMS 发送结果的主要内容,如果未能解决你的问题,请参考以下文章

在 Android 中发送和接收 SMS 和 MMS(Kit Kat Android 4.4 之前)

xml 示例如何使用Unity3D和SMS Manager在Android中发送SMS。 (无需打开SMS Composer)

Android 上的 0 类 SMS(闪存 SMS)

通过 SMS 发送的位置链接在 Android 浏览器中有效,但在 iPhone 浏览器中无效

(转)Android短信的发送和接收监听

java.lang.SecurityException:发送短信:uid 10051 没有 android.permission.SEND_SMS [重复]