如何在listview中加载短信对话

时间:2016-08-11 05:40:18

标签: android

任何人都可以在使用以下代码段后解释如何在listview中加载短信对话。

ContentResolver contentResolver = getContentResolver();
final String[] projection = new String[]{"*"};
Uri uri = Uri.parse("content://mms-sms/conversations/");
Cursor query = contentResolver.query(uri, projection, null, null, null);

1 个答案:

答案 0 :(得分:0)

// Create Inbox box URI
Uri inboxURI = Uri.parse("content://sms/inbox");

// List required columns
String[] reqCols = new String[] { "_id", "address", "body" };

// Get Content Resolver object, which will deal with Content Provider
ContentResolver cr = getContentResolver();

// Fetch Inbox SMS Message from Built-in Content Provider
Cursor c = cr.query(inboxURI, reqCols, null, null, null);

还在清单

中设置权限
<uses-permission android:name="android.permission.READ_SMS"></uses-permission>