短信发送/交付广播接收器 [英] SMS Sent/Delivered Broadcast Receiver

查看:129
本文介绍了短信发送/交付广播接收器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


  

可能重复:结果
  广播接收器发送短信


当通过广播接收器接收,像这样短信我目前检测:

 <接收机器人:名字=。gathering.SMSNode>
    &所述;意图滤光器>
        <作用机器人:名字=android.provider.Telephony.SMS_RECEIVED/>
    &所述; /意图滤光器>
< /接收器>

是否有检测时发送消息类似的广播接收器?


解决方案

  ContentResolver的ContentResolver的= getContentResolver();
处理程序处理程序=新的处理程序();
m_SMSObserver =新SMSObserver(处理);
contentResolver.registerContentObserver(Uri.parse(内容://短信),
真的,m_SMSObserver);而这code分离发送/接收事件乌里uriSMSURI = Uri.parse(内容:// SMS);
光标CUR = this.getContentResolver()查询(uriSMSURI,NULL,NULL,
NULL,NULL);
cur.moveToNext();
字符串协议= cur.getString(cur.getColumnIndex(协议));
如果(协议== NULL)
        onSMSSend();
其他
        onSMSReceive();

您可以借此以供参考:

http://www.mail-archive.com/ android-developers@googlegroups.com/msg27154.html

Possible Duplicate:
Broadcast Receiver for Sent SMS

I am currently detecting when an SMS is received through a broadcast receiver like so:

<receiver android:name=".gathering.SMSNode">
    <intent-filter>
        <action android:name="android.provider.Telephony.SMS_RECEIVED" />
    </intent-filter>
</receiver>

Is there a similar broadcast receiver for detecting when a message is sent?

解决方案

ContentResolver contentResolver = getContentResolver();
Handler handler = new Handler();
m_SMSObserver = new SMSObserver(handler);
contentResolver.registerContentObserver(Uri.parse("content://sms"),
true, m_SMSObserver);

And this code for separating send/receive events

Uri uriSMSURI = Uri.parse("content://sms");
Cursor cur = this.getContentResolver().query(uriSMSURI, null, null,
null, null);
cur.moveToNext();
String protocol = cur.getString(cur.getColumnIndex("protocol"));
if(protocol == null)
        onSMSSend();            
else
        onSMSReceive(); 

You can take this for reference:

http://www.mail-archive.com/android-developers@googlegroups.com/msg27154.html

这篇关于短信发送/交付广播接收器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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