We need to read both the inbound and outbound text messages from a phone. I have done much googling and have found a number of sources, such as:
Detecting SMS incoming and outgoing How to use SMS content provider? Where are the docs? Android read SMS messages
to name a few.
From my research, I have written the following code:
Uri allMessages = Uri.parse("content://sms/inbox");
Cursor cursor = airApp.getContentResolver().query(allMessages, null, null, null, null);
if(cursor.moveToFirst()){
do {
for (int i = 0; i < cursor.getColumnCount(); i++) {
log.debug(cursor.getColumnName(i) + "=" + cursor.getString(i) + "");
}
log.debug("One row finished **************************************************");
} while (cursor.moveToNext());
}
The problem is that cursor is always null. I checked the permissions and they are:
<uses-permission android:name="android.permission.SEND_SMS" />
<uses-permission android:name="android.permission.READ_SMS" />
<uses-permission android:name="android.permission.WRITE_SMS" />
<uses-permission android:name="android.permission.RECEIVE_MMS" />
Any ideas why I'd be getting a null cursor?