5

How can I run an Android application in the background that counts the number of SMS messages sent and, in addition, determine the detail of each one?

gonzobrains
  • 7,856
  • 14
  • 81
  • 132
Asshwani Singh
  • 171
  • 2
  • 11

1 Answers1

2

you can fetch sent msg:

    Uri mSmsinboxQueryUri = Uri.parse("content://sms/sent");
    Cursor cursor1 = getContentResolver().query(mSmsinboxQueryUri,
                new String[] { "_id", "thread_id", "address", "person", "date",
                                "body", "type" }, null, null, null);
    startManagingCursor(cursor1);
    String[] columns = new String[] { "address", "person", "date", "body","type" };
    if (cursor1.getCount() > 0) {
        String count = Integer.toString(cursor1.getCount());
        Log.e("Count",count);
        while (cursor1.moveToNext()){
            String address = cursor1.getString(cursor1.getColumnIndex(columns[0]));
            String name = cursor1.getString(cursor1.getColumnIndex(columns[1]));
            String date = cursor1.getString(cursor1.getColumnIndex(columns[2]));
            String msg = cursor1.getString(cursor1.getColumnIndex(columns[3]));
            String type = cursor1.getString(cursor1.getColumnIndex(columns[4]));
        }
    }

you can use counter to retrive recently sent sms.

See other useful links:

Android: Is there any way to listen outgoing sms?

Listen outgoing SMS or sent box in Android

How to listen/subscribe to Outgoing SMS notifications?

Community
  • 1
  • 1
Vineet Shukla
  • 23,865
  • 10
  • 55
  • 63
  • For some reason content://sms/sent doesn't work for me but content://sms/ does. Why do you think this is the case? – gonzobrains May 19 '13 at 14:41