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?
Asked
Active
Viewed 8,422 times
1 Answers
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?

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