Reputation: 1052
I'm writing an app which needs to read the user's text messages for it's basic operation. Google says, SMS content provider is not supported and may not be present in certain phones, or may not work in future versions of Android. I would like to know if anyone knows of any specific phones without the SMS content provider? I know the question has already been asked -
Is there any phone that doesn't have sms inbox content provider? but no one has provided an answer. Alternatively, if someone could suggest a way of reading incoming and outgoing messages using a standard API, that would be even better.
Upvotes: 3
Views: 1614
Reputation: 1052
I haven't been able to find a phone without an SMS content provider (at least from Google searches). I don't think manufacturers would take the risk of breaking compatibility with the numerous SMS applications out there (which all use this private API). Also, at this point there seems to be no standard way to access both incoming and outgoing messages.
Update: This has been made a public API with 4.4 - https://developer.android.com/reference/android/provider/Telephony.html
Upvotes: 3
Reputation: 2250
Uri mSmsinboxQueryUri = Uri.parse("content://sms");
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()) {
out.write("<message>");
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]));
}
}
and
Uri mSmsinboxQueryUri = Uri.parse("content://sms/inbox");
Uri mSmsinboxQueryUri = Uri.parse("content://sms/sent");
Use this uri u can read inbox as well as the sent items.
And the user permission in the manifest file is
<uses-permission android:name="android.permission.READ_SMS" />
Upvotes: 2