Android的短信发送结果

Android的短信发送结果

本文介绍了Android的短信发送结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在开发Android短信应用。我想保存邮件状态(例如,交货时)

但在发送短信时,接收器总是返回RESULT_OK。这是code我使用的是:

  Main.context.registerReceiver(新广播接收器(){
        @覆盖
        公共无效的onReceive(上下文为arg0,ARG1意向){
            开关(的getResult code()){
            案例Activity.RESULT_OK:                Main.log(短信发送);
                LogThread logThreadEntregado =新LogThread(主,SMSID);
                logThreadEntregado.setEntregado();
                螺纹T6 =新主题(logThreadEntregado);
                // t6.run();
                Main.mHandler.post(T6);
                Main.context.unregisterReceiver(本);
                打破;
            案例Activity.RESULT_CANCELED:
                Main.log(短信未送达);
                LogThread logThreadNoEntregado =新LogThread(主,SMSID);
                logThreadNoEntregado.setNoEntregado();
                螺纹T7 =新主题(logThreadNoEntregado);
                Main.mHandler.post(T7);
                Main.context.unregisterReceiver(本);
                // t7.run();
                打破;
            }
        }
    },新的IntentFilter(送到));

我想知道是否有一种方法(可能与参数上下文为arg0,ARG1意向),以检查是否该消息已被果然不负众望。

感谢您提前


解决方案

将Kannel的送你回去你在短信提交DLR-url参数指定的URL发送报告,例如example.com/DLR?outgoing_id = 123安培。状态=%d个

什么语言你写它是无关紧要的。所有你需要的是通过HTTP GET接受特定参数的HTTP页面。将Kannel的添加参数的交货状态,时间等,你将通过它的ID将其链接到您的短信提交如上。

这个讨论 有一个明显的例子。

I'm developing a SMS app for android. And I want to save the message state (ex, when delivered)

But the receiver returns always a RESULT_OK when sending a SMS. This is the code I'm using:

        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));

I want to know if there's a way (maybe with the arguments Context arg0, Intent arg1) to check if the message has been really delivered.

Thank you in advance

解决方案

Kannel will send you back the delivery reports in the url you specify in the dlr-url parameter in the SMS submission, for example example.com/DLR?outgoing_id=123&status=%d.

What language you write it in is irrelevant. All you need is an HTTP page that accepts specific parameters via HTTP GET. Kannel will add parameters for the delivery status, time, et al, and you will link them to your SMS submission via its id as above.

This discussion has a clear example.

这篇关于Android的短信发送结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 18:32