开发者

How to detect outgoing SMS messages in the backgound of an Android application?

开发者 https://www.devze.com 2023-04-03 09:48 出处:网络
How can I run an Android application in the background that counts the number of SMS messages sent and, in addition, determine the deta开发者_高级运维il of each one?you can fetch sent msg:

How can I run an Android application in the background that counts the number of SMS messages sent and, in addition, determine the deta开发者_高级运维il of each one?


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?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号