2

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?

Community
  • 1
  • 1
Aelexe
  • 1,216
  • 3
  • 18
  • 27
  • The question linked only listed alternatives, but never stated whether a receiver existed or not. – Aelexe Dec 23 '12 at 06:17

1 Answers1

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

Check the following url for reference:

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

Siroj Matchanov
  • 101
  • 2
  • 4
vanloi999
  • 485
  • 4
  • 13