We have an Android app where we are trying to read all the messages available in the phone. We are using READ_SMS permission but we are not able to read service messages in this way. By service mesaage I mean the messages obtained from different companies. For example I have messages in my phone from Amazon and Paytm but I am not able to load these while loading messages. I don't understand the issue. Is there any default filter that android is applying when the SMS get loaded or is there any issue with the code?
I use the following code to load all SMS:
private ArrayList load_sms(){
ContentResolver contentResolver = getContentResolver();
ArrayList<String> smsList = new ArrayList<>();
Cursor smsInboxCursor =
contentResolver.query(Uri.parse("content://sms/inbox"),
null,null,null,null);
int indexBody = smsInboxCursor.getColumnIndex("body");
int indexAddress = smsInboxCursor.getColumnIndex("address");
if(indexBody < 0 || !smsInboxCursor.moveToFirst())
return null;
do{
smsList.add("SMS From: " +
smsInboxCursor.getString(indexAddress) + " \nMessage: "
+ smsInboxCursor.getString(indexBody));
}while (smsInboxCursor.moveToNext());
return smsList;
}