任何没有短信内容提供商的Android手机?
问题描述:
我正在写一个应用程序,它需要阅读用户的短信才能进行基本操作。谷歌表示,短信内容提供商不受支持,可能不会出现在某些手机中,或可能不适用于未来版本的Android。我想知道是否有人知道没有短信内容提供商的任何特定手机?我知道这个问题已被问到 -任何没有短信内容提供商的Android手机?
Is there any phone that doesn't have sms inbox content provider?但没有人提供了答案。 或者,如果有人可以建议使用标准API读取传入和传出邮件的方式,那会更好。
答
我一直没能找到一个电话没有(从谷歌搜索至少)短信内容提供商。我不认为制造商会冒着破坏与众多SMS应用程序兼容性的风险(这些应用程序都使用此私有API)。 此外,在这一点上似乎没有标准的方式来访问传入和传出的消息。
更新:这已经作出了公开的API与4.4 - https://developer.android.com/reference/android/provider/Telephony.html
答
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]));
}
}
和
Uri mSmsinboxQueryUri = Uri.parse("content://sms/inbox");
Uri mSmsinboxQueryUri = Uri.parse("content://sms/sent");
使用这个URI u能读取收件箱以及已发送的邮件。
而且在清单文件中的用户权限是
<uses-permission android:name="android.permission.READ_SMS" />
也许你误解了我的问题。我想知道是否有人遇到没有SMS内容提供商的手机,或者是否有标准的“官方”方式访问收件箱。您的解决方案使用隐藏的API。 – BlueSilver 2011-06-14 18:21:11