user1239393
user1239393

Reputation: 125

Access Inbox message from Android application

I need a help in Android sms application. I am sending a message from my android application to a mobile number. I need to check if the message has been delivered in INBOX of that mobile number from my application. I need to check the message sent to mobile number has been delivered. Ie. Desitnation matches. How to access INBOX messge from android application. Please guide me in this issue. It will be of great help if someone helps me with sample working example.

Thanks in advance.

Upvotes: 2

Views: 4179

Answers (2)

Sunny
Sunny

Reputation: 14838

try this

 public static final Uri SMS_INBOX_CONTENT_URI = Uri.parse("content://sms/inbox");

 Cursor cursor = managedQuery(SMS_INBOX_CONTENT_URI, new String[]{TextSmsColumns.ID, TextSmsColumns.ADDRESS,
            TextSmsColumns.DATE, TextSmsColumns.BODY}, null, null, TextSmsColumns.DATE + " DESC");

    cursor.moveToFirst();
    StringBuilder builder = new StringBuilder();
    for(int i = 0 ; i < cursor.getCount(); i++)
    {
        builder.append("         ID-"+i);
        String s= "  Address:  "+cursor.getString(cursor.getColumnIndexOrThrow(TextSmsColumns.ADDRESS))
        + "  Body:  "+cursor.getString(cursor.getColumnIndexOrThrow(TextSmsColumns.BODY))
        + "  Date:  "+cursor.getString(cursor.getColumnIndexOrThrow(TextSmsColumns.DATE));
        builder.append(s);
        cursor.moveToNext();
    }

Upvotes: 0

Lucifer
Lucifer

Reputation: 29670

How to Access INBOX messagr from android application, answer is below,

Uri uri = Uri.parse("content://sms/inbox");
Cursor cursor = context.getContentResolver().query(uri, null, null, null, null);
while (cursor.moveToNext()) 
{
  // Retrieve sms
  // see column "address" for comparing

  // Then update the sms and set the column "read" to 1
}

Upvotes: 1

Related Questions