As long as the receiver has kept the sms in their inbox, you can use the following code, from this thread:
// public static final String INBOX = "content://sms/inbox";
// public static final String SENT = "content://sms/sent";
// public static final String DRAFT = "content://sms/draft";
Cursor cursor = getContentResolver().query(Uri.parse("content://sms/inbox"), null, null, null, null);
if (cursor.moveToFirst()) { // must check the result to prevent exception
do {
String msgData = "";
for(int idx=0;idx<cursor.getColumnCount();idx++)
{
msgData += " " + cursor.getColumnName(idx) + ":" + cursor.getString(idx);
}
// use msgData
} while (cursor.moveToNext());
} else {
// empty box, no SMS
}
This code will store all the message data as a string within the msgData
variable. You can then search within for your target sender's phone number, your app information, etc.
To implement this strategy, you'd simply have to call the above code on the first run of the app. Note that you have also have to add the permission: android.permission.READ_SMS
in case you hadn't already.