2012-12-23 140 views
2

可能重复:
Broadcast Receiver for Sent SMSSMS发送/递送广播接收机

当通过广播接收器接收到的SMS像这样我目前检测:

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

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

+0

问题挂钩唯一一家上市的替代品,但从来没有说是否接收器是否存在。 – Aelexe

回答

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

而这种代码分离发送/接收事件

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

检查以下网址以供参考:

http://www.mail-archive.com/[email protected]/msg27154.html