ContentObserver's onChange() skips some SMS sending Group SMS
<p>I want to observe the <code>sent</code> and <code>received</code> SMS in my Application. Receiving SMS works fine, but there is a problem in sending SMS. When user sends multiple SMS one after another(Group SMS) at the same time, some of the SMS are skipped(no logs in the onChange()). Also, <code>onChange()</code> is getting called twice as cursor that is observed is being updated two times. So, can anyone tell me what is the problem here. How can I get all the sent SMS detail in sent SMS. below is my code for observing the sent and received SMS.</p>

<p><code>onChange()</code> method implementation,</p>

<pre><code>@Override
    public void onChange(boolean selfChange) {
        super.onChange(selfChange);

        Log.d(getClass().getSimpleName(), "onChanged called");
        Cursor cursor = mContext.getContentResolver().query(Uri
                                .parse("content://sms"), null, null, null, null);
        if (cursor != null) {
            if (cursor.moveToFirst()) {
                Log.d("Message Body and ID ",cursor.getString(cursor
                                                       .getColumnIndex("body")));
            } 
        }
    }
</code></pre>

<p>Also I refered some links/answers that insisted using <code>deliverSelfNotifications()</code> to return true to restricted <code>onChange()</code> being called twice, but this is also not working. It still gets called twice.</p>

<pre><code>@Override
    public boolean deliverSelfNotifications() {
        return true;
    }
</code></pre>

<p>Below is my Logcat output, when I sent 4 message from the Emulator/Device
Aaaa, Bbbb, Cccc, Dddd and it only gave me details for the last two messages and first two got skipped.</p>

<pre><code>03-12 18:51:19.809: DEBUG/MyContentObserver(1354): onChanged called
03-12 18:51:21.458: DEBUG/MyContentObserver(1354): onChanged called
03-12 18:51:22.648: DEBUG/MyContentObserver(1354): onChanged called
03-12 18:51:25.508: DEBUG/MyContentObserver(1354): onChanged called
03-12 18:51:28.568: DEBUG/MyContentObserver(1354): onChanged called
03-12 18:51:28.812: WARN/dalvikvm(103): JNI: pin count on array 0x40051200 ([C) is now 11
03-12 18:51:28.841: WARN/dalvikvm(103): JNI: pin count on array 0x40051200 ([C) is now 11
03-12 18:51:28.841: WARN/dalvikvm(103): JNI: pin count on array 0x40051200 ([C) is now 11
03-12 18:51:28.841: WARN/dalvikvm(103): JNI: pin count on array 0x40051200 ([C) is now 11
03-12 18:51:30.348: DEBUG/dalvikvm(103): GREF has increased to 601
03-12 18:51:31.798: DEBUG/dalvikvm(189): GREF has increased to 501
03-12 18:51:32.529: DEBUG/dalvikvm(103): GC freed 8501 objects / 577704 bytes in 447ms
03-12 18:51:32.998: DEBUG/dalvikvm(189): GC freed 13158 objects / 515104 bytes in 324ms
03-12 18:51:33.538: DEBUG/MyContentObserver(1354): onChanged called
03-12 18:51:33.768: WARN/KeyCharacterMap(189): No keyboard for id 0
03-12 18:51:33.778: WARN/KeyCharacterMap(189): Using default keymap: /system/usr/keychars/qwerty.kcm.bin
03-12 18:51:35.194: DEBUG/Message Body and ID(1354): Cccc
03-12 18:51:35.548: DEBUG/MyContentObserver(1354): onChanged called
03-12 18:51:37.658: DEBUG/MyContentObserver(1354): onChanged called
03-12 18:51:38.308: DEBUG/Message Body and ID(1354): Ddd
</code></pre>

<p>As you can see I only got Cccc and Dddd in the logcat output. So, can anyone give me the solution/reason why this is happening and what can I do to get the first two messages also.</p>
